You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't want to have the django-debug-toolbar package installed in my production environment, so I'm looking for alternatives to a slightly "dirty" import which is not at the top of the file (see PEP-402):
if "debug_toolbar" in settings.INSTALLED_APPS:
import debug_toolbar
urlpatterns.append(url(r"^__debug__/", include(debug_toolbar.urls)))
seems to work, so I wonder why this isn't documented. Are there any downsides to this approach, or might this stop to work in future versions of the django debug toolbar?
To be honest: I have no idea why we couldn't make include("debug_toolbar.urls") work (except for time and energy, always excellent reasons)
Maybe it has to do with old ways of declaring URLconf namespaces or maybe something to do with the magical auto-installation of the toolbar which has been removed a few years ago.
I don't want to have the
django-debug-toolbar
package installed in my production environment, so I'm looking for alternatives to a slightly "dirty" import which is not at the top of the file (see PEP-402):But the obvious string-module-path
fails due to the error
ModuleNotFoundError: No module named 'debug_toolbar.urls'
.However, I noticed that
seems to work, so I wonder why this isn't documented. Are there any downsides to this approach, or might this stop to work in future versions of the django debug toolbar?
Thanks for any comments on this!
Django version: 3.2.7
Django Debug Toolbar version: 3.2.2
The text was updated successfully, but these errors were encountered: