An admin page with a checkbox to enable the Django Debug Toolbar.
Project description
Debug Toolbar Checkbox
Demo
Install
$ 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:
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")),
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.tar.gz.
File metadata
- Download URL: django_debug_toolbar_checkbox-0.1.tar.gz
- Upload date:
- Size: 78.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
37aed7f163de791e6760e00495a2c3050306aadc967770b9e1411cb9f3750124
|
|
| MD5 |
53960b28df8f63d2eca13dabcba9bae7
|
|
| BLAKE2b-256 |
406690fe0dfe64edb7aa336c439ab5186122fed48c97067626ca115ad4acdb23
|
File details
Details for the file django_debug_toolbar_checkbox-0.1-py3-none-any.whl.
File metadata
- Download URL: django_debug_toolbar_checkbox-0.1-py3-none-any.whl
- Upload date:
- Size: 5.4 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 |
d7c774450ac7809bc7c5db3932a3e260922dc6bcc0a0c8a37413ae849809288f
|
|
| MD5 |
3f138ba2b9159243701c393f8ecc5dfa
|
|
| BLAKE2b-256 |
116c07fe0991b9836c31ada681cefb0387f662bd7d3e44d47ce57392600b98d3
|