From 4902043da88f76fdc14b765998ca2524064f0f6c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Fri, 3 Nov 2023 10:13:28 -0400 Subject: [PATCH] Reference public models registry when populating models for ConfigTemplate context --- netbox/extras/models/configs.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/netbox/extras/models/configs.py b/netbox/extras/models/configs.py index 2acfcb725..425c1386a 100644 --- a/netbox/extras/models/configs.py +++ b/netbox/extras/models/configs.py @@ -260,12 +260,14 @@ class ConfigTemplate(SyncedDataMixin, ExportTemplatesMixin, TagsMixin, ChangeLog _context = dict() # 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['model_features']['custom_fields'].items(): + for app, model_names in registry['models'].items(): _context.setdefault(app, {}) for model_name in model_names: - model = apps.get_registered_model(app, model_name) - _context[app][model.__name__] = model + try: + model = apps.get_registered_model(app, model_name) + _context[app][model.__name__] = model + except LookupError: + pass # Add the provided context data, if any if context is not None: