Closed simonw closed 3 years ago
I'm going to copy the pattern used by django-debug-toolbar
:
import debug_toolbar
from django.conf import settings
from django.urls import include, path
urlpatterns = [
...
path('__debug__/', include(debug_toolbar.urls)),
]
Where debug_toolbar.urls
is defined here: https://github.com/jazzband/django-debug-toolbar/blob/8b280e196e21b73de10f22cc9bae0d566777dc35/debug_toolbar/__init__.py
urls = "debug_toolbar.toolbar", "djdt"
And debug_toolbar/toolbar.py
contains this: https://github.com/jazzband/django-debug-toolbar/blob/8b280e196e21b73de10f22cc9bae0d566777dc35/debug_toolbar/toolbar.py
# ...
@classmethod
def get_urls(cls):
if cls._urlpatterns is None:
from . import views
# Load URLs in a temporary variable for thread safety.
# Global URLs
urlpatterns = [
path("render_panel/", views.render_panel, name="render_panel")
]
# Per-panel URLs
for panel_class in cls.get_panel_classes():
urlpatterns += panel_class.get_urls()
cls._urlpatterns = urlpatterns
return cls._urlpatterns
# ...
urlpatterns = DebugToolbar.get_urls()
Urgent instructions are to do this:
Using
include()
here would be better, especially since the paths need to have fixed names that can be referenced in the templates.