django-devbar 0.3.0__tar.gz → 0.4.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {django_devbar-0.3.0 → django_devbar-0.4.0}/PKG-INFO +34 -19
- django_devbar-0.4.0/README.md +82 -0
- {django_devbar-0.3.0 → django_devbar-0.4.0}/pyproject.toml +1 -1
- {django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/conf.py +5 -3
- {django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/middleware.py +15 -16
- {django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/templates/django_devbar/devbar.html +4 -3
- {django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/tracker.py +0 -1
- django_devbar-0.3.0/README.md +0 -67
- {django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/__init__.py +0 -0
- {django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/templates/django_devbar/duplicates.html +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: django-devbar
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.4.0
|
|
4
4
|
Summary: Lightweight performance devbar for Django
|
|
5
5
|
Keywords: django,debug,performance,monitoring,development
|
|
6
6
|
Author: amureki
|
|
@@ -33,11 +33,24 @@ Description-Content-Type: text/markdown
|
|
|
33
33
|
|
|
34
34
|
Lightweight performance devbar for Django. Shows DB query count, query duration, application time, and detects duplicate queries with visual severity indicators.
|
|
35
35
|
|
|
36
|
-

|
|
36
|
+
Normal operation – showing query count, duration, and application time: 
|
|
37
37
|
|
|
38
|
-

|
|
38
|
+
Duplicate queries detected – severity indicator and details shown: 
|
|
39
39
|
|
|
40
|
-
|
|
40
|
+
[](#chrome-extension)
|
|
41
|
+
|
|
42
|
+
> [!WARNING]
|
|
43
|
+
> This package is experimental and may introduce breaking changes in minor versions.
|
|
44
|
+
|
|
45
|
+
## Motivation
|
|
46
|
+
|
|
47
|
+
While [Django Debug Toolbar](https://django-debug-toolbar.readthedocs.io/) is a proven tool trusted by countless projects, django-devbar explores a different approach to development debugging:
|
|
48
|
+
|
|
49
|
+
- **Minimal setup** — just add middleware, nothing else required
|
|
50
|
+
- **Browser DevTools integration** — Chrome extension panel works with any response type, including JSON
|
|
51
|
+
- **Zero extra dependencies** — only requires Django
|
|
52
|
+
- **Lower overhead** — no extra requests to debug endpoints
|
|
53
|
+
- **Non-intrusive** — HTML bar is optional; works via headers and DevTools panel alone
|
|
41
54
|
|
|
42
55
|
## Installation
|
|
43
56
|
|
|
@@ -65,34 +78,36 @@ All settings are optional. Configure via a `DEVBAR` dict in your Django settings
|
|
|
65
78
|
|
|
66
79
|
```python
|
|
67
80
|
DEVBAR = {
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
81
|
+
"POSITION": "bottom-right", # bottom-right (default), bottom-left, top-right, top-left
|
|
82
|
+
"SHOW_BAR": None, # follows DEBUG; set True/False to override
|
|
83
|
+
"ENABLE_DEVTOOLS_DATA": None, # follows DEBUG; set True/False to override
|
|
71
84
|
}
|
|
72
85
|
```
|
|
73
86
|
|
|
74
87
|
## Response Headers
|
|
75
88
|
|
|
76
|
-
|
|
89
|
+
Django DevBar adds HTTP response headers with performance metrics:
|
|
90
|
+
|
|
91
|
+
- **Server-Timing** (always present) – Standard HTTP header with database, application, and total time metrics. Visible in Chrome DevTools Network tab under Timing.
|
|
92
|
+
|
|
93
|
+
An additional header is included by default in DEBUG mode:
|
|
94
|
+
|
|
95
|
+
- **DevBar-Data** - JSON header with comprehensive metrics including duplicate query details
|
|
96
|
+
|
|
97
|
+
This is useful for:
|
|
77
98
|
|
|
78
99
|
- **API endpoints** where the HTML overlay can't be displayed
|
|
79
100
|
- **Automated testing** to assert performance metrics (e.g., fail CI if query count exceeds a limit)
|
|
80
|
-
- **
|
|
101
|
+
- **Browser extensions** that need detailed duplicate query information
|
|
81
102
|
|
|
82
|
-
|
|
103
|
+
### Server-Timing format
|
|
83
104
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
| `DevBar-DB-Time` | `87ms` | Total time spent in database queries |
|
|
88
|
-
| `DevBar-App-Time` | `41ms` | Application time (total time minus DB time) |
|
|
89
|
-
| `DevBar-Duplicates` | `3` | Number of duplicate queries detected (only present if duplicates found) |
|
|
105
|
+
```
|
|
106
|
+
Server-Timing: db;dur=87.50, app;dur=41.30, total;dur=128.80
|
|
107
|
+
```
|
|
90
108
|
|
|
91
109
|
## Chrome Extension
|
|
92
110
|
|
|
93
|
-

|
|
94
|
-
|
|
95
111
|
View Django DevBar metrics directly in Chrome DevTools with the [official extension](https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid).
|
|
96
|
-
Requires `DEVBAR = {'SHOW_HEADERS': True}`.
|
|
97
112
|
|
|
98
113
|
See [chrome-extension/README.md](chrome-extension/README.md) for more details.
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# django-devbar
|
|
2
|
+
|
|
3
|
+
Lightweight performance devbar for Django. Shows DB query count, query duration, application time, and detects duplicate queries with visual severity indicators.
|
|
4
|
+
|
|
5
|
+
Normal operation – showing query count, duration, and application time: 
|
|
6
|
+
|
|
7
|
+
Duplicate queries detected – severity indicator and details shown: 
|
|
8
|
+
|
|
9
|
+
[](#chrome-extension)
|
|
10
|
+
|
|
11
|
+
> [!WARNING]
|
|
12
|
+
> This package is experimental and may introduce breaking changes in minor versions.
|
|
13
|
+
|
|
14
|
+
## Motivation
|
|
15
|
+
|
|
16
|
+
While [Django Debug Toolbar](https://django-debug-toolbar.readthedocs.io/) is a proven tool trusted by countless projects, django-devbar explores a different approach to development debugging:
|
|
17
|
+
|
|
18
|
+
- **Minimal setup** — just add middleware, nothing else required
|
|
19
|
+
- **Browser DevTools integration** — Chrome extension panel works with any response type, including JSON
|
|
20
|
+
- **Zero extra dependencies** — only requires Django
|
|
21
|
+
- **Lower overhead** — no extra requests to debug endpoints
|
|
22
|
+
- **Non-intrusive** — HTML bar is optional; works via headers and DevTools panel alone
|
|
23
|
+
|
|
24
|
+
## Installation
|
|
25
|
+
|
|
26
|
+
```bash
|
|
27
|
+
# Using uv (recommended)
|
|
28
|
+
uv add --dev django-devbar
|
|
29
|
+
|
|
30
|
+
# Or using pip
|
|
31
|
+
pip install django-devbar
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Add to your middleware as early as possible, but after any middleware that encodes the response (e.g., `GZipMiddleware`):
|
|
35
|
+
|
|
36
|
+
```python
|
|
37
|
+
MIDDLEWARE = [
|
|
38
|
+
"django.middleware.security.SecurityMiddleware",
|
|
39
|
+
"django_devbar.DevBarMiddleware",
|
|
40
|
+
# ...
|
|
41
|
+
]
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## Configuration
|
|
45
|
+
|
|
46
|
+
All settings are optional. Configure via a `DEVBAR` dict in your Django settings:
|
|
47
|
+
|
|
48
|
+
```python
|
|
49
|
+
DEVBAR = {
|
|
50
|
+
"POSITION": "bottom-right", # bottom-right (default), bottom-left, top-right, top-left
|
|
51
|
+
"SHOW_BAR": None, # follows DEBUG; set True/False to override
|
|
52
|
+
"ENABLE_DEVTOOLS_DATA": None, # follows DEBUG; set True/False to override
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Response Headers
|
|
57
|
+
|
|
58
|
+
Django DevBar adds HTTP response headers with performance metrics:
|
|
59
|
+
|
|
60
|
+
- **Server-Timing** (always present) – Standard HTTP header with database, application, and total time metrics. Visible in Chrome DevTools Network tab under Timing.
|
|
61
|
+
|
|
62
|
+
An additional header is included by default in DEBUG mode:
|
|
63
|
+
|
|
64
|
+
- **DevBar-Data** - JSON header with comprehensive metrics including duplicate query details
|
|
65
|
+
|
|
66
|
+
This is useful for:
|
|
67
|
+
|
|
68
|
+
- **API endpoints** where the HTML overlay can't be displayed
|
|
69
|
+
- **Automated testing** to assert performance metrics (e.g., fail CI if query count exceeds a limit)
|
|
70
|
+
- **Browser extensions** that need detailed duplicate query information
|
|
71
|
+
|
|
72
|
+
### Server-Timing format
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
Server-Timing: db;dur=87.50, app;dur=41.30, total;dur=128.80
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Chrome Extension
|
|
79
|
+
|
|
80
|
+
View Django DevBar metrics directly in Chrome DevTools with the [official extension](https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid).
|
|
81
|
+
|
|
82
|
+
See [chrome-extension/README.md](chrome-extension/README.md) for more details.
|
|
@@ -12,7 +12,7 @@ def get_config():
|
|
|
12
12
|
return {
|
|
13
13
|
"POSITION": "bottom-right",
|
|
14
14
|
"SHOW_BAR": None, # None = use settings.DEBUG
|
|
15
|
-
"
|
|
15
|
+
"ENABLE_DEVTOOLS_DATA": None, # None = use settings.DEBUG
|
|
16
16
|
**getattr(settings, "DEVBAR", {}),
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -29,5 +29,7 @@ def get_show_bar():
|
|
|
29
29
|
return settings.DEBUG if show_bar is None else show_bar
|
|
30
30
|
|
|
31
31
|
|
|
32
|
-
def
|
|
33
|
-
|
|
32
|
+
def get_enable_devtools_data():
|
|
33
|
+
config = get_config()
|
|
34
|
+
enable = config["ENABLE_DEVTOOLS_DATA"]
|
|
35
|
+
return settings.DEBUG if enable is None else enable
|
|
@@ -9,9 +9,9 @@ from django.template import Context, Engine
|
|
|
9
9
|
|
|
10
10
|
from . import tracker
|
|
11
11
|
from .conf import (
|
|
12
|
+
get_enable_devtools_data,
|
|
12
13
|
get_position,
|
|
13
14
|
get_show_bar,
|
|
14
|
-
get_show_headers,
|
|
15
15
|
)
|
|
16
16
|
|
|
17
17
|
BODY_CLOSE_RE = re.compile(rb"</body\s*>", re.IGNORECASE)
|
|
@@ -46,36 +46,36 @@ class DevBarMiddleware:
|
|
|
46
46
|
stats["python_time"] = python_time
|
|
47
47
|
stats["total_time"] = total_time
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
if get_enable_devtools_data():
|
|
50
|
+
self._add_devtools_data_header(response, stats)
|
|
50
51
|
|
|
51
|
-
|
|
52
|
-
self._add_headers(response, stats)
|
|
52
|
+
self._add_server_timing_header(response, stats)
|
|
53
53
|
|
|
54
54
|
if get_show_bar() and self._can_inject(response):
|
|
55
|
-
self._inject_devbar(response, stats
|
|
55
|
+
self._inject_devbar(response, stats)
|
|
56
56
|
|
|
57
57
|
return response
|
|
58
58
|
|
|
59
|
-
def
|
|
60
|
-
response["DevBar-Query-Count"] = str(stats["count"])
|
|
61
|
-
response["DevBar-DB-Time"] = f"{stats['duration']:.0f}ms"
|
|
62
|
-
response["DevBar-App-Time"] = f"{stats['python_time']:.0f}ms"
|
|
63
|
-
if stats["has_duplicates"]:
|
|
64
|
-
response["DevBar-Duplicates"] = str(len(stats["duplicate_queries"]))
|
|
65
|
-
|
|
66
|
-
# Add comprehensive JSON data for browser DevTools extension
|
|
59
|
+
def _add_devtools_data_header(self, response, stats):
|
|
67
60
|
extension_data = {
|
|
68
61
|
"count": stats["count"],
|
|
69
62
|
"db_time": stats["duration"],
|
|
70
63
|
"app_time": stats["python_time"],
|
|
71
64
|
"total_time": stats["total_time"],
|
|
72
|
-
"has_duplicates": stats["has_duplicates"],
|
|
73
65
|
}
|
|
74
66
|
if stats.get("duplicate_queries"):
|
|
75
67
|
extension_data["duplicates"] = stats["duplicate_queries"]
|
|
76
68
|
|
|
77
69
|
response["DevBar-Data"] = json.dumps(extension_data)
|
|
78
70
|
|
|
71
|
+
def _add_server_timing_header(self, response, stats):
|
|
72
|
+
parts = [
|
|
73
|
+
f"db;dur={stats['duration']:.2f}",
|
|
74
|
+
f"app;dur={stats['python_time']:.2f}",
|
|
75
|
+
f"total;dur={stats['total_time']:.2f}",
|
|
76
|
+
]
|
|
77
|
+
response["Server-Timing"] = ", ".join(parts)
|
|
78
|
+
|
|
79
79
|
def _can_inject(self, response):
|
|
80
80
|
if getattr(response, "streaming", False):
|
|
81
81
|
return False
|
|
@@ -86,7 +86,7 @@ class DevBarMiddleware:
|
|
|
86
86
|
return False
|
|
87
87
|
return hasattr(response, "content")
|
|
88
88
|
|
|
89
|
-
def _inject_devbar(self, response, stats
|
|
89
|
+
def _inject_devbar(self, response, stats):
|
|
90
90
|
content = response.content
|
|
91
91
|
matches = list(BODY_CLOSE_RE.finditer(content))
|
|
92
92
|
if not matches:
|
|
@@ -101,7 +101,6 @@ class DevBarMiddleware:
|
|
|
101
101
|
Context(
|
|
102
102
|
{
|
|
103
103
|
"position": get_position(),
|
|
104
|
-
"level": level,
|
|
105
104
|
"db_time": stats["duration"],
|
|
106
105
|
"app_time": stats["python_time"],
|
|
107
106
|
"query_count": stats["count"],
|
{django_devbar-0.3.0 → django_devbar-0.4.0}/src/django_devbar/templates/django_devbar/devbar.html
RENAMED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
color: #f5f5f5;
|
|
15
15
|
}
|
|
16
16
|
#django-devbar.level-warn { border-left: 3px solid #f59e0b; }
|
|
17
|
+
#django-devbar.has-duplicates { border-left: 3px solid #f59e0b; }
|
|
17
18
|
#django-devbar span { opacity: 0.7; }
|
|
18
19
|
#django-devbar strong { opacity: 1; font-weight: 600; }
|
|
19
20
|
#django-devbar details { display: inline; position: relative; }
|
|
@@ -85,8 +86,8 @@
|
|
|
85
86
|
}
|
|
86
87
|
@media (max-width: 640px) { #django-devbar { display: none; } }
|
|
87
88
|
</style>
|
|
88
|
-
<div id="django-devbar" class="
|
|
89
|
+
<div id="django-devbar"{% if duplicates_html %} class="has-duplicates"{% endif %}>
|
|
90
|
+
<span>queries</span> <strong>{{ query_count }}</strong> <span>·</span>
|
|
89
91
|
<span>db</span> <strong>{{ db_time|floatformat:0 }}ms</strong> <span>·</span>
|
|
90
|
-
<span>app</span> <strong>{{ app_time|floatformat:0 }}ms</strong>
|
|
91
|
-
<span>queries</span> <strong>{{ query_count }}</strong>{{ duplicates_html|safe }}
|
|
92
|
+
<span>app</span> <strong>{{ app_time|floatformat:0 }}ms</strong>{{ duplicates_html|safe }}
|
|
92
93
|
</div>
|
django_devbar-0.3.0/README.md
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
# django-devbar
|
|
2
|
-
|
|
3
|
-
Lightweight performance devbar for Django. Shows DB query count, query duration, application time, and detects duplicate queries with visual severity indicators.
|
|
4
|
-
|
|
5
|
-

|
|
6
|
-
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
> **Note:** This package is experimental and may introduce breaking changes in minor versions.
|
|
10
|
-
|
|
11
|
-
## Installation
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
# Using uv (recommended)
|
|
15
|
-
uv add --dev django-devbar
|
|
16
|
-
|
|
17
|
-
# Or using pip
|
|
18
|
-
pip install django-devbar
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
Add to your middleware as early as possible, but after any middleware that encodes the response (e.g., `GZipMiddleware`):
|
|
22
|
-
|
|
23
|
-
```python
|
|
24
|
-
MIDDLEWARE = [
|
|
25
|
-
"django.middleware.security.SecurityMiddleware",
|
|
26
|
-
"django_devbar.DevBarMiddleware",
|
|
27
|
-
# ...
|
|
28
|
-
]
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
## Configuration
|
|
32
|
-
|
|
33
|
-
All settings are optional. Configure via a `DEVBAR` dict in your Django settings:
|
|
34
|
-
|
|
35
|
-
```python
|
|
36
|
-
DEVBAR = {
|
|
37
|
-
'POSITION': 'bottom-right', # bottom-right, bottom-left, top-right, top-left
|
|
38
|
-
'SHOW_BAR': None, # None (default) = follows DEBUG, or True/False to override
|
|
39
|
-
'SHOW_HEADERS': False, # Add DevBar-* headers to responses
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
## Response Headers
|
|
44
|
-
|
|
45
|
-
When `DEVBAR = {'SHOW_HEADERS': True}`, performance metrics are added as HTTP response headers. This is useful for:
|
|
46
|
-
|
|
47
|
-
- **API endpoints** where the HTML overlay can't be displayed
|
|
48
|
-
- **Automated testing** to assert performance metrics (e.g., fail CI if query count exceeds a limit)
|
|
49
|
-
- **Monitoring tools** that can capture and aggregate header values
|
|
50
|
-
|
|
51
|
-
Headers included:
|
|
52
|
-
|
|
53
|
-
| Header | Example | Description |
|
|
54
|
-
|--------|---------|-------------|
|
|
55
|
-
| `DevBar-Query-Count` | `12` | Number of database queries executed |
|
|
56
|
-
| `DevBar-DB-Time` | `87ms` | Total time spent in database queries |
|
|
57
|
-
| `DevBar-App-Time` | `41ms` | Application time (total time minus DB time) |
|
|
58
|
-
| `DevBar-Duplicates` | `3` | Number of duplicate queries detected (only present if duplicates found) |
|
|
59
|
-
|
|
60
|
-
## Chrome Extension
|
|
61
|
-
|
|
62
|
-

|
|
63
|
-
|
|
64
|
-
View Django DevBar metrics directly in Chrome DevTools with the [official extension](https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid).
|
|
65
|
-
Requires `DEVBAR = {'SHOW_HEADERS': True}`.
|
|
66
|
-
|
|
67
|
-
See [chrome-extension/README.md](chrome-extension/README.md) for more details.
|
|
File without changes
|
|
File without changes
|