{"id":1454,"library":"django-debug-toolbar","title":"Django Debug Toolbar","description":"Django Debug Toolbar is a configurable set of panels that display various debug information about the current request/response in Django applications. It is actively maintained by the Django Commons organization, with new releases typically coming out every few months, often tied to Django's release cycle and Python version support. The current version is 6.3.0.","status":"active","version":"6.3.0","language":"en","source_language":"en","source_url":"https://github.com/django-commons/django-debug-toolbar","tags":["django","debugging","development","profiling","web"],"install":[{"cmd":"pip install django-debug-toolbar","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core dependency for the debug toolbar to function. Requires Django 4.2+ for current versions, compatible with Python >=3.10.","package":"Django","optional":false}],"imports":[{"symbol":"DebugToolbarMiddleware","correct":"from debug_toolbar.middleware import DebugToolbarMiddleware"},{"symbol":"debug_toolbar.urls","correct":"import debug_toolbar"}],"quickstart":{"code":"# settings.py\nimport os\n\nDEBUG = True # Essential for debug_toolbar to appear\n\nINSTALLED_APPS = [\n    # ... your other apps\n    \"django.contrib.admin\",\n    \"django.contrib.auth\",\n    \"django.contrib.contenttypes\",\n    \"django.contrib.sessions\",\n    \"django.contrib.messages\",\n    \"django.contrib.staticfiles\",\n    \n    \"debug_toolbar\", # Add debug_toolbar to your INSTALLED_APPS\n]\n\nMIDDLEWARE = [\n    # ... Django's default middleware ...\n    \"django.middleware.security.SecurityMiddleware\",\n    \"django.contrib.sessions.middleware.SessionMiddleware\",\n    \"debug_toolbar.middleware.DebugToolbarMiddleware\", # Place early in middleware list\n    \"django.middleware.common.CommonMiddleware\",\n    \"django.middleware.csrf.CsrfViewMiddleware\",\n    \"django.contrib.auth.middleware.AuthenticationMiddleware\",\n    \"django.contrib.messages.middleware.MessageMiddleware\",\n    \"django.middleware.clickjacking.XFrameOptionsMiddleware\",\n    # ... your custom middleware ...\n]\n\n# Configure INTERNAL_IPS for the toolbar to show up\nINTERNAL_IPS = [\n    \"127.0.0.1\",\n    \"::1\", # IPv6 localhost\n    # If running in Docker, WSL, or remotely, add your development machine's IP, e.g.,\n    # \"172.17.0.1\", # Common for Docker host\n    # os.environ.get(\"YOUR_DEV_IP\", \"\"), # Dynamic IP example\n]\n\n# Optional: Customize toolbar behavior (e.g., disable panels)\nDEBUG_TOOLBAR_CONFIG = {\n    \"DISABLE_PANELS\": [\n        \"debug_toolbar.panels.redirects.RedirectsPanel\" # Example: disable redirects panel\n    ],\n    \"SHOW_TOOLBAR_CALLBACK\": \"debug_toolbar.utils.show_toolbar_callback\",\n}\n\n\n# urls.py\nfrom django.contrib import admin\nfrom django.urls import path, include\nfrom django.conf import settings\n\nif settings.DEBUG:\n    import debug_toolbar # Only import if DEBUG is True\n    urlpatterns = [\n        path(\"__debug__/\", include(debug_toolbar.urls)),\n        path(\"admin/\", admin.site.urls),\n        # ... your other app paths ...\n    ]\nelse:\n    urlpatterns = [\n        path(\"admin/\", admin.site.urls),\n        # ... your other app paths ...\n    ]\n","lang":"python","description":"To quickly set up Django Debug Toolbar, first install the package. Then, modify your Django project's `settings.py` by adding `'debug_toolbar'` to `INSTALLED_APPS` and `'debug_toolbar.middleware.DebugToolbarMiddleware'` to `MIDDLEWARE`. Crucially, configure `INTERNAL_IPS` to include your development machine's IP address(es) for the toolbar to be visible. Finally, add the debug toolbar's URLs to your project's `urls.py`, typically conditional on `settings.DEBUG` being `True`."},"warnings":[{"fix":"Review any custom panels and update logic for data storage according to the new panel data persistence system. Be aware of automatic sanitization of sensitive data in displayed information.","message":"Version 6.0.0 significantly revamped how panel data is persisted, introducing configurable backends (memory, database). Custom panels or previous assumptions about panel data handling may require updates. Additionally, sensitive information is now filtered using `SafeExceptionReporterFilter.cleanse_setting()`.","severity":"breaking","affected_versions":">=6.0.0"},{"fix":"Ensure your project runs on Python 3.9+ (preferably 3.10+ for current versions of Django). Thoroughly test your middleware chain and async views after upgrading.","message":"Version 5.0.0 dropped support for Python 3.8. The project moved to the Django Commons organization. Significant changes were made to the middleware for improved async compatibility, which might affect highly customized middleware setups or existing async applications.","severity":"breaking","affected_versions":">=5.0.0"},{"fix":"Add `INTERNAL_IPS = ['127.0.0.1', '::1', 'your_dev_ip_here']` to your `settings.py`. For dynamic environments, consider using environment variables to populate this list.","message":"The `INTERNAL_IPS` setting is mandatory for the toolbar to appear. By default, the toolbar only shows for requests originating from these specified IP addresses. If you're using Docker, WSL, a remote development environment, or a non-standard localhost setup, you must ensure your client's IP is included.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Place `'debug_toolbar.middleware.DebugToolbarMiddleware'` early in your `MIDDLEWARE` list, typically after `SecurityMiddleware` and `SessionMiddleware` but before other processing middleware like `CommonMiddleware`.","message":"The placement of `DebugToolbarMiddleware` in your `MIDDLEWARE` list is crucial. It generally needs to be placed *after* any middleware that modifies the response (e.g., `CompressionMiddleware`, `CommonMiddleware`) but *before* middleware that expects a complete response and may prematurely close it.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Replace `'debug_toolbar.panels.redirects.RedirectsPanel'` with `'debug_toolbar.panels.history.HistoryPanel'` in your `DEBUG_TOOLBAR_PANELS` setting if you have customized your panel list.","message":"As of version 6.2.0, `RedirectsPanel` has been deprecated in favor of the more robust `HistoryPanel`. While `RedirectsPanel` still functions, it is recommended to update your `DEBUG_TOOLBAR_PANELS` setting if you explicitly listed it.","severity":"deprecated","affected_versions":">=6.2.0"},{"fix":"Ensure `DEBUG = True` in your development `settings.py` file. Use separate settings files or environment variables to manage `DEBUG` for different environments.","message":"The Django `DEBUG` setting must be set to `True` for the toolbar to activate and display. The toolbar will not render in production environments where `DEBUG` is `False`.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-09T00:00:00.000Z","next_check":"2026-07-08T00:00:00.000Z"}