Note_Tech

All technological notes.


Project maintained by simonangel-fong Hosted on GitHub Pages — Theme by mattgraham

Django Library - django-debug-toolbar

Back


Django Debug Toolbar


Intall

$ python -m pip install django-debug-toolbar

Prerequisites

  1. Ensure that ‘django.contrib.staticfiles’ is in your INSTALLED_APPS setting, and configured properly:
  2. Ensure that your TEMPLATES setting contains a DjangoTemplates backend whose APP_DIRS options is set to True ```py

    settings.py

    INSTALLED_APPS = [ “django.contrib.staticfiles”, ]

STATIC_URL = “static/”

TEMPLATES = [ { “BACKEND”: “django.template.backends.django.DjangoTemplates”, “APP_DIRS”: True, } ]


---

### Install the App

```py
INSTALLED_APPS = [
    "debug_toolbar",
]

Add the URLs

from django.urls import include, path

urlpatterns = [
    path("__debug__/", include("debug_toolbar.urls")),  # __debug__ can be any url prefix that do not clash with URLConfs.
]

Add the Middleware

MIDDLEWARE = [
    "debug_toolbar.middleware.DebugToolbarMiddleware",
]

Configure Internal IPs

INTERNAL_IPS = [
    "127.0.0.1",        # debut message will display on this url.
]

Top