An admin page with a checkbox to enable the Django Debug Toolbar.
Project description
Debug Toolbar Checkbox
Demo
Install
First install the Django Debug Toolbar, if not already done.
$ pip install debug_toolbar_checkbox
In settings.py, add debug_toolbar_checkbox before django admin:
INSTALLED_APPS = [
"debug_toolbar",
"debug_toolbar_checkbox",
"django.contrib.admin",
...,
]
In settings.py set a DEBUG_TOOLBAR_SETTINGS, or derive it from SECRET_KEY:
from hashlib import sha256
DEBUG_TOOLBAR_SECRET = sha256(b"djdt" + SECRET_KEY.encode("UTF-8")).hexdigest()
In settings.py configure the Debug Toolbar to check the secret in the cookie:
DEBUG_TOOLBAR_CONFIG = {
"SHOW_TOOLBAR_CALLBACK": lambda request: DEBUG_TOOLBAR_SECRET in request.headers.get("cookie", "")
}
In urls.py add this before the path("admin/"):
path("admin/pages/", include("debug_toolbar_checkbox.urls")),
You may need to add include to the from django.urls import path line.
It may look like this:
from debug_toolbar.toolbar import debug_toolbar_urls
from django.contrib import admin
from django.urls import include, path
urlpatterns = [
path("admin/pages/", include("debug_toolbar_checkbox.urls")),
path("admin/", admin.site.urls),
] + debug_toolbar_urls()
Security
The activation is governed by the presence of a secret in a cookie. The cookie is set by some JavaScript (static file, publicly available). But the secret is only written in the admin page as a data attribute. The admin page is only accessible to superusers, so only superusers can query the page containing the secret.
If you're not OK with my sha256/concat to derive a new secret, feel free to replace it with a truly random secret.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_debug_toolbar_checkbox-0.1.2.tar.gz.
File metadata
- Download URL: django_debug_toolbar_checkbox-0.1.2.tar.gz
- Upload date:
- Size: 78.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
532406693bae530d9ec22788ee9943ba730d4db582e211811a0716b2eed19cb5
|
|
| MD5 |
fad71501bbbe9b20e049e36f2309c3b6
|
|
| BLAKE2b-256 |
5bd007ce5947f1773a41dc475a781c34b5463ec01b4652c96ea9e0dfdd67d69c
|
File details
Details for the file django_debug_toolbar_checkbox-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_debug_toolbar_checkbox-0.1.2-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9657e39dea8e1fe1215be60fa33c855d999ec20b813e65310a786b1574b1acdc
|
|
| MD5 |
d644d76162ac1f617ce54234631dccf4
|
|
| BLAKE2b-256 |
4db91ffa2e981a0b9c0791d46ac84e1d6c1e3540e9cbb811ebfb5fb8e3d80cfb
|