mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-19 09:53:34 -06:00
Closes #17029: Deprecate PluginTemplateExtension.model
This commit is contained in:
parent
5b8ef2eb44
commit
6aeb553391
@ -1,4 +1,5 @@
|
|||||||
import inspect
|
import inspect
|
||||||
|
import warnings
|
||||||
|
|
||||||
from django.utils.translation import gettext_lazy as _
|
from django.utils.translation import gettext_lazy as _
|
||||||
from netbox.registry import registry
|
from netbox.registry import registry
|
||||||
@ -37,7 +38,12 @@ def register_template_extensions(class_list):
|
|||||||
# Registration for multiple models
|
# Registration for multiple models
|
||||||
models = template_extension.models
|
models = template_extension.models
|
||||||
elif template_extension.model:
|
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]
|
models = [template_extension.model]
|
||||||
else:
|
else:
|
||||||
# Global registration (no specific models)
|
# Global registration (no specific models)
|
||||||
|
@ -21,7 +21,7 @@ class PluginTemplateExtension:
|
|||||||
* config - Plugin-specific configuration parameters
|
* config - Plugin-specific configuration parameters
|
||||||
"""
|
"""
|
||||||
models = None
|
models = None
|
||||||
model = None
|
model = None # Deprecated; use `models` instead
|
||||||
|
|
||||||
def __init__(self, context):
|
def __init__(self, context):
|
||||||
self.context = context
|
self.context = context
|
||||||
|
Loading…
Reference in New Issue
Block a user