From 6aeb5533914ad5369eccd3891c1b9c59f9ef7f8c Mon Sep 17 00:00:00 2001 From: Jeremy Stretch Date: Thu, 17 Oct 2024 15:58:05 -0400 Subject: [PATCH] Closes #17029: Deprecate PluginTemplateExtension.model --- netbox/netbox/plugins/registration.py | 8 +++++++- netbox/netbox/plugins/templates.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/netbox/netbox/plugins/registration.py b/netbox/netbox/plugins/registration.py index c84572794..515405f1b 100644 --- a/netbox/netbox/plugins/registration.py +++ b/netbox/netbox/plugins/registration.py @@ -1,4 +1,5 @@ import inspect +import warnings from django.utils.translation import gettext_lazy as _ from netbox.registry import registry @@ -37,7 +38,12 @@ def register_template_extensions(class_list): # Registration for multiple models models = template_extension.models elif template_extension.model: - # Registration for a single model + # Registration for a single model (deprecated) + warnings.warn( + "PluginTemplateExtension.model is deprecated and will be removed in a future release. Use " + "'models' instead.", + DeprecationWarning + ) models = [template_extension.model] else: # Global registration (no specific models) diff --git a/netbox/netbox/plugins/templates.py b/netbox/netbox/plugins/templates.py index e1f4b7a47..4ea90b4db 100644 --- a/netbox/netbox/plugins/templates.py +++ b/netbox/netbox/plugins/templates.py @@ -21,7 +21,7 @@ class PluginTemplateExtension: * config - Plugin-specific configuration parameters """ models = None - model = None + model = None # Deprecated; use `models` instead def __init__(self, context): self.context = context