Closes #21157: Add public models to export template context #175

Closed
opened 2026-04-05 16:22:40 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jnovinger on 3/10/2026

Fixes: #21157

Move shared get_context() logic from ConfigTemplate into RenderTemplateMixin so ExportTemplate also gets access to all public model classes. This enables export templates to perform cross-model lookups (e.g. resolving a parent Prefix from an IPAddress).

ConfigTemplate already populated these models via ObjectType.objects.public(). This was identical boilerplate that belonged in the shared base class. ConfigTemplate's override is removed (it inherits the base behavior), and ExportTemplate now calls super().get_context() before adding queryset.

*Originally created by @jnovinger on 3/10/2026* ### Fixes: #21157 Move shared `get_context()` logic from `ConfigTemplate` into `RenderTemplateMixin` so `ExportTemplate` also gets access to all public model classes. This enables export templates to perform cross-model lookups (e.g. resolving a parent `Prefix` from an `IPAddress`). `ConfigTemplate` already populated these models via `ObjectType.objects.public()`. This was identical boilerplate that belonged in the shared base class. `ConfigTemplate`'s override is removed (it inherits the base behavior), and `ExportTemplate` now calls `super().get_context()` before adding `queryset`.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#175