mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-23 07:56:44 -06:00
Reference public models registry when populating models for ConfigTemplate context
This commit is contained in:
parent
859557d542
commit
4902043da8
@ -260,12 +260,14 @@ class ConfigTemplate(SyncedDataMixin, ExportTemplatesMixin, TagsMixin, ChangeLog
|
|||||||
_context = dict()
|
_context = dict()
|
||||||
|
|
||||||
# Populate the default template context with NetBox model classes, namespaced by app
|
# Populate the default template context with NetBox model classes, namespaced by app
|
||||||
# TODO: Devise a canonical mechanism for identifying the models to include (see #13427)
|
for app, model_names in registry['models'].items():
|
||||||
for app, model_names in registry['model_features']['custom_fields'].items():
|
|
||||||
_context.setdefault(app, {})
|
_context.setdefault(app, {})
|
||||||
for model_name in model_names:
|
for model_name in model_names:
|
||||||
|
try:
|
||||||
model = apps.get_registered_model(app, model_name)
|
model = apps.get_registered_model(app, model_name)
|
||||||
_context[app][model.__name__] = model
|
_context[app][model.__name__] = model
|
||||||
|
except LookupError:
|
||||||
|
pass
|
||||||
|
|
||||||
# Add the provided context data, if any
|
# Add the provided context data, if any
|
||||||
if context is not None:
|
if context is not None:
|
||||||
|
Loading…
Reference in New Issue
Block a user