diff --git a/config/settings.py b/config/settings.py index b33f33a..1a79554 100644 --- a/config/settings.py +++ b/config/settings.py @@ -334,7 +334,9 @@ if DEBUG and _IS_DEV and not _IS_RUNNING_TESTS: # Don't auto-collapse the SQL panel — the SQL count is the # main thing we check on every page. 'SHOW_COLLAPSED': False, - # Explicit check so the toolbar ONLY renders when the hosting - # flags are still set (guards against stale cached pages). - 'SHOW_TOOLBAR_CALLBACK': lambda request: DEBUG and _IS_DEV, + # This callback is invoked per-request by the toolbar's middleware. + # Since we only REACH this config block when the triple gate + # (DEBUG + _IS_DEV + not running tests) already passed at settings + # load time, there's nothing to re-check here — just return True. + 'SHOW_TOOLBAR_CALLBACK': lambda request: True, } diff --git a/config/urls.py b/config/urls.py index f9043f6..1a992cb 100644 --- a/config/urls.py +++ b/config/urls.py @@ -15,11 +15,10 @@ if settings.DEBUG: # === DEV-ONLY: Django Debug Toolbar URL include === # Matches the conditional load in settings.py. No-op in prod. +# The settings.py gate already guarantees debug_toolbar is importable +# by the time we get here, so no try/except is needed. If we ever +# downgrade to a toolbar version older than v4.0 (which introduced +# debug_toolbar_urls), swap this for `path('__debug__/', include(debug_toolbar.urls))`. if 'debug_toolbar' in settings.INSTALLED_APPS: - try: - from debug_toolbar.toolbar import debug_toolbar_urls - urlpatterns += debug_toolbar_urls() - except ImportError: - import debug_toolbar - from django.urls import include, path - urlpatterns += [path('__debug__/', include(debug_toolbar.urls))] \ No newline at end of file + from debug_toolbar.toolbar import debug_toolbar_urls + urlpatterns += debug_toolbar_urls() \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index b1240ee..c24208f 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,4 @@ mysqlclient==2.2.7 python-dotenv==1.1.1 pillow==12.1.1 weasyprint==68.1 -django-debug-toolbar==6.0.0 \ No newline at end of file +django-debug-toolbar==6.0.0 # dev-only — gated in config/settings.py, never active in prod \ No newline at end of file