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.
Release files for django-debug-toolbar-checkbox 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| django_debug_toolbar_checkbox-0.1.2.tar.gz | 78.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| django_debug_toolbar_checkbox-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 84.4 kB
Release files / django_debug_toolbar_checkbox-0.1.2.tar.gz
| Download URL | django_debug_toolbar_checkbox-0.1.2.tar.gz |
|---|---|
| Size | 78.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
532406693bae530d9ec22788ee9943ba730d4db582e211811a0716b2eed19cb5
|
|
BLAKE2b-256 checksum How to use checksums |
5bd007ce5947f1773a41dc475a781c34b5463ec01b4652c96ea9e0dfdd67d69c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|
Release files / django_debug_toolbar_checkbox-0.1.2-py3-none-any.whl
| Download URL | django_debug_toolbar_checkbox-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9657e39dea8e1fe1215be60fa33c855d999ec20b813e65310a786b1574b1acdc
|
|
BLAKE2b-256 checksum How to use checksums |
4db91ffa2e981a0b9c0791d46ac84e1d6c1e3540e9cbb811ebfb5fb8e3d80cfb
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.12
|