diff --git a/docs/configuration/miscellaneous.md b/docs/configuration/miscellaneous.md index 4d4ca189e..7e68bcee7 100644 --- a/docs/configuration/miscellaneous.md +++ b/docs/configuration/miscellaneous.md @@ -99,6 +99,14 @@ The maximum size (in bytes) of an incoming HTTP request (i.e. `GET` or `POST` da --- +## DJANGO_ADMIN_ENABLED + +Default: False + +Setting this to True installs the `django.contrib.admin` app and enables the [Django admin UI](https://docs.djangoproject.com/en/5.0/ref/contrib/admin/). This may be necessary to support older plugins which do not integrate with the native NetBox interface. + +--- + ## ENFORCE_GLOBAL_UNIQUE !!! tip "Dynamic Configuration Parameter" diff --git a/netbox/netbox/settings.py b/netbox/netbox/settings.py index bc7603fc4..8e40686c1 100644 --- a/netbox/netbox/settings.py +++ b/netbox/netbox/settings.py @@ -115,6 +115,7 @@ DEFAULT_PERMISSIONS = getattr(configuration, 'DEFAULT_PERMISSIONS', { 'users.delete_token': ({'user': '$user'},), }) DEVELOPER = getattr(configuration, 'DEVELOPER', False) +DJANGO_ADMIN_ENABLED = getattr(configuration, 'DJANGO_ADMIN_ENABLED', False) DOCS_ROOT = getattr(configuration, 'DOCS_ROOT', os.path.join(os.path.dirname(BASE_DIR), 'docs')) EMAIL = getattr(configuration, 'EMAIL', {}) EVENTS_PIPELINE = getattr(configuration, 'EVENTS_PIPELINE', ( @@ -355,7 +356,6 @@ SERVER_EMAIL = EMAIL.get('FROM_EMAIL') # INSTALLED_APPS = [ - 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', @@ -393,6 +393,9 @@ INSTALLED_APPS = [ 'drf_spectacular_sidecar', ] +if DJANGO_ADMIN_ENABLED: + INSTALLED_APPS.insert(0, 'django.contrib.admin') + # Middleware MIDDLEWARE = [ 'graphiql_debug_toolbar.middleware.DebugToolbarMiddleware', diff --git a/netbox/netbox/tests/test_plugins.py b/netbox/netbox/tests/test_plugins.py index 40bf8b0ea..e956c00b9 100644 --- a/netbox/netbox/tests/test_plugins.py +++ b/netbox/netbox/tests/test_plugins.py @@ -32,6 +32,7 @@ class PluginTest(TestCase): instance.delete() self.assertIsNone(instance.pk) + @override_settings(DJANGO_ADMIN_ENABLED=True) def test_admin(self): # Test admin view URL resolution diff --git a/netbox/netbox/urls.py b/netbox/netbox/urls.py index 38044a613..43cfc1d4f 100644 --- a/netbox/netbox/urls.py +++ b/netbox/netbox/urls.py @@ -11,7 +11,6 @@ from netbox.graphql.schema import schema from netbox.graphql.views import GraphQLView from netbox.plugins.urls import plugin_patterns, plugin_api_patterns from netbox.views import HomeView, StaticMediaFailureView, SearchView, htmx -from .admin import admin_site _patterns = [ @@ -70,26 +69,25 @@ _patterns = [ # Plugins path('plugins/', include((plugin_patterns, 'plugins'))), path('api/plugins/', include((plugin_api_patterns, 'plugins-api'))), - - # Admin - path('admin/', admin_site.urls), ] +# Django admin UI +if settings.DJANGO_ADMIN_ENABLED: + from .admin import admin_site + _patterns.append(path('admin/', admin_site.urls)) +# django-debug-toolbar if settings.DEBUG: import debug_toolbar - _patterns += [ - path('__debug__/', include(debug_toolbar.urls)), - ] + _patterns.append(path('__debug__/', include(debug_toolbar.urls))) +# Prometheus metrics if settings.METRICS_ENABLED: - _patterns += [ - path('', include('django_prometheus.urls')), - ] + _patterns.append(path('', include('django_prometheus.urls'))) # Prepend BASE_PATH urlpatterns = [ - path('{}'.format(settings.BASE_PATH), include(_patterns)) + path(settings.BASE_PATH, include(_patterns)) ] handler404 = 'netbox.views.errors.handler_404' diff --git a/netbox/templates/account/profile.html b/netbox/templates/account/profile.html index 07c701de2..fb6da891a 100644 --- a/netbox/templates/account/profile.html +++ b/netbox/templates/account/profile.html @@ -38,7 +38,7 @@ {% checkmark request.user.is_superuser %} - {% trans "Admin Access" %} + {% trans "Staff" %} {% checkmark request.user.is_staff %} diff --git a/netbox/templates/core/configrevision_restore.html b/netbox/templates/core/configrevision_restore.html index 884abafe8..0097f93e5 100644 --- a/netbox/templates/core/configrevision_restore.html +++ b/netbox/templates/core/configrevision_restore.html @@ -45,7 +45,11 @@ {{ param }} {{ current }} {{ new }} - {% if current != new %}*{% endif %} + + {% if current != new %} + + {% endif %} + {% endfor %} diff --git a/netbox/templates/inc/user_menu.html b/netbox/templates/inc/user_menu.html index 5beca96dc..95bc639c0 100644 --- a/netbox/templates/inc/user_menu.html +++ b/netbox/templates/inc/user_menu.html @@ -9,9 +9,9 @@