Pārlūkot izejas kodu

Remove the `models` key from the application registry (closes #21891)

Drops the deprecated registry['models'] key, the __getitem__ deprecation
warning, and the population code in register_model(). Registered models
should be retrieved via ObjectType.objects.public() instead.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Jeremy Stretch 2 nedēļas atpakaļ
vecāks
revīzija
3b145a9c3d

+ 13 - 0
docs/release-notes/version-4.7.md

@@ -0,0 +1,13 @@
+# NetBox v4.7
+
+## v4.7.0 (FUTURE)
+
+### Breaking Changes
+
+### Enhancements
+
+### Other Changes
+
+* [#21891](https://github.com/netbox-community/netbox/issues/21891) - Remove the `models` key from the application registry (use `ObjectType.objects.public()` instead)
+
+### REST API Changes

+ 1 - 1
netbox/netbox/context_processors.py

@@ -38,7 +38,7 @@ def preferences(request):
 
 def registry(request):
     """
-    Adds NetBox registry items to the template context. Example: {{ registry.models.core }}
+    Adds NetBox registry items to the template context.
     """
     return {
         'registry': registry_,

+ 0 - 5
netbox/netbox/models/features.py

@@ -723,11 +723,6 @@ def register_models(*models):
     for model in models:
         app_label, model_name = model._meta.label_lower.split('.')
 
-        # TODO: Remove in NetBox v4.7
-        # Register public models (access the underlying dict directly to avoid triggering the deprecation warning)
-        if not getattr(model, '_netbox_private', False):
-            dict.__getitem__(registry, 'models')[app_label].add(model_name)
-
         # Register applicable feature views for the model
         if issubclass(model, ContactsMixin):
             register_model_view(model, 'contacts', kwargs={'model': model})(

+ 0 - 11
netbox/netbox/registry.py

@@ -9,15 +9,6 @@ class Registry(dict):
     removed (though the value of each key is mutable).
     """
     def __getitem__(self, key):
-        # TODO: Remove in NetBox v4.7
-        if key == 'models':
-            import warnings
-            warnings.warn(
-                'The "models" registry key is deprecated and will be removed in NetBox v4.7. Registered models can be '
-                'obtained by calling ObjectType.objects.public().',
-                DeprecationWarning,
-                stacklevel=2,
-            )
         try:
             return super().__getitem__(key)
         except KeyError:
@@ -39,8 +30,6 @@ registry = Registry({
     'filtersets': dict(),
     'model_actions': collections.defaultdict(set),
     'model_features': dict(),
-    # TODO: Remove in NetBox v4.7
-    'models': collections.defaultdict(set),
     'plugins': dict(),
     'request_processors': list(),
     'search': dict(),