Repository: nautobot/nautobot

Issue:
Rework nav menu and homepage registry data to not be part of global template context
### Proposed Changes

Either:
1) Remove the `nautobot.extras.registry.registry` from the global Nautobot template rendering context altogether and provide templatetags that can instead be used to reference it as needed in specific contexts
2) Omit the `nav_menu` and `homepage_layout` registry data from the template rendering context at least.

<!-- Provide justification for the proposed change(s). -->
### Justification

The global view template rendering context currently includes the entire `nautobot.extras.registry.registry` dictionary, which currently includes all data under the `nav_menu` and `homepage_layout` keys. When developing/debugging view templates using the django-debug-toolbar, this results in literal pages of context data, making for a subpar developer experience. The `nav_menu` data should only be needed when rendering `inc/nav_menu.html` and the `homepage_layout` data should only be needed when rendering the actual Nautobot home page; in all other templates these are just noise.


Discussion:

Resolving patch:
diff --git a/nautobot/core/context_processors.py b/nautobot/core/context_processors.py
--- a/nautobot/core/context_processors.py
+++ b/nautobot/core/context_processors.py
@@ -1,7 +1,6 @@
 from django.conf import settings as django_settings
 
 from nautobot.core.settings_funcs import sso_auth_enabled
-from nautobot.extras.registry import registry
 
 
 def get_saml_idp():
@@ -30,14 +29,13 @@ def get_saml_idp():
     return value
 
 
-def settings_and_registry(request):
+def settings(request):
     """
-    Expose Django settings and Nautobot registry stores in the template context. Example: {{ settings.DEBUG }}
+    Expose Django settings in the template context. Example: {{ settings.DEBUG }}
     """
 
     return {
         "settings": django_settings,
-        "registry": registry,
     }
 
 
diff --git a/nautobot/core/settings.py b/nautobot/core/settings.py
--- a/nautobot/core/settings.py
+++ b/nautobot/core/settings.py
@@ -347,7 +347,7 @@
                 "django.contrib.messages.context_processors.messages",
                 "social_django.context_processors.backends",
                 "social_django.context_processors.login_redirect",
-                "nautobot.core.context_processors.settings_and_registry",
+                "nautobot.core.context_processors.settings",
                 "nautobot.core.context_processors.sso_auth",
             ],
         },
@@ -366,7 +366,7 @@
                 "django.contrib.messages.context_processors.messages",
                 "social_django.context_processors.backends",
                 "social_django.context_processors.login_redirect",
-                "nautobot.core.context_processors.settings_and_registry",
+                "nautobot.core.context_processors.settings",
                 "nautobot.core.context_processors.sso_auth",
             ],
         },
diff --git a/nautobot/extras/templatetags/registry.py b/nautobot/extras/templatetags/registry.py
new file mode 100644
--- /dev/null
+++ b/nautobot/extras/templatetags/registry.py
@@ -0,0 +1,22 @@
+from django import template
+
+from nautobot.extras.registry import registry
+
+register = template.Library()
+
+
+class RegistryNode(template.Node):
+    """Companion to the do_registry() function that sets `registry` as a context variable for the template."""
+
+    def __init__(self):
+        pass
+
+    def render(self, context):
+        context["registry"] = registry
+        return ""
+
+
+@register.tag(name="registry")
+def do_registry(parser, token):
+    """Provide access to the Nautobot data registry as context variable `registry` within this block."""
+    return RegistryNode()


Test patch: