pip install django-debug-toolbar
- In
settings
make sure that static files is set up and APP_DIRS
in TEMPLATES
is set to True
.
- Install in
settings
:
INSTALLED_APPS += ["debug_toolbar"]
MIDDLEWARE += ["debug_toolbar.middleware.DebugToolbarMiddleware"]
INTERNAL_IPS = ["127.0.0.1"]
DEBUG_TOOLBAR_CONFIG = {"ROOT_TAG_EXTRA_ATTRS": "hx-preserve"}
urlpatterns = [
path("__debug__/", include("debug_toolbar.urls")),
]
- if using HTMX add following to
base.html
template:
{% if debug %}
window.addEventListener("load", (event) => {
if (typeof window.htmx !== "undefined") {
htmx.on("htmx:afterSettle", function(detail) {
if (
typeof window.djdt !== "undefined"
&& detail.target instanceof HTMLBodyElement
) {
djdt.show_toolbar();
}
});
}
});
{% endif %}