django-devbar 0.7.0__tar.gz → 1.0.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-1.0.0/PKG-INFO +161 -0
- django_devbar-1.0.0/README.md +127 -0
- django_devbar-1.0.0/pyproject.toml +68 -0
- django_devbar-0.7.0/pyproject.toml → django_devbar-1.0.0/pyproject.toml.orig +3 -1
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/middleware.py +3 -0
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/tracker.py +5 -11
- django_devbar-0.7.0/PKG-INFO +0 -133
- django_devbar-0.7.0/README.md +0 -101
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/__init__.py +0 -0
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/conf.py +0 -0
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/templates/django_devbar/devbar.html +0 -0
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/templates/django_devbar/duplicates.html +0 -0
- {django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/templates/django_devbar/similar.html +0 -0
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: django-devbar
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: Lightweight performance devbar for Django
|
|
5
|
+
Keywords: django,debug,performance,monitoring,development
|
|
6
|
+
Author: amureki
|
|
7
|
+
Author-email: amureki <oss@amureki.me>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
Classifier: Development Status :: 5 - Production/Stable
|
|
10
|
+
Classifier: Programming Language :: Python
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
18
|
+
Classifier: Framework :: Django
|
|
19
|
+
Classifier: Framework :: Django :: 4.2
|
|
20
|
+
Classifier: Framework :: Django :: 5.0
|
|
21
|
+
Classifier: Framework :: Django :: 5.1
|
|
22
|
+
Classifier: Framework :: Django :: 5.2
|
|
23
|
+
Classifier: Framework :: Django :: 6.0
|
|
24
|
+
Classifier: Topic :: Software Development
|
|
25
|
+
Classifier: Intended Audience :: Developers
|
|
26
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
27
|
+
Requires-Dist: django>=4.2
|
|
28
|
+
Requires-Python: >=3.10
|
|
29
|
+
Project-URL: Homepage, https://github.com/amureki/django-devbar
|
|
30
|
+
Project-URL: Repository, https://github.com/amureki/django-devbar
|
|
31
|
+
Project-URL: Issues, https://github.com/amureki/django-devbar/issues
|
|
32
|
+
Project-URL: Funding, https://github.com/sponsors/amureki
|
|
33
|
+
Description-Content-Type: text/markdown
|
|
34
|
+
|
|
35
|
+
# django-devbar
|
|
36
|
+
|
|
37
|
+
A performance bar for Django development. Shows database query counts, query duration,
|
|
38
|
+
and application time. Flags similar and duplicate queries.
|
|
39
|
+
|
|
40
|
+
Settings and the response header format remain compatible within 1.x.
|
|
41
|
+
Breaking changes require a new major version.
|
|
42
|
+
|
|
43
|
+
[![Badge PyPI]][pypi]
|
|
44
|
+
[![Badge Chrome]][chrome]
|
|
45
|
+
[![Badge Firefox]][firefox]
|
|
46
|
+
|
|
47
|
+
## Install
|
|
48
|
+
|
|
49
|
+
| Component | Install from | Notes |
|
|
50
|
+
| :------------------------- | :------------------------- | :-------------------------------- |
|
|
51
|
+
| Django package | [PyPI] | `uv add --dev django-devbar` |
|
|
52
|
+
| Chrome DevTools extension | [Chrome Web Store][chrome] | Optional |
|
|
53
|
+
| Firefox DevTools extension | [Firefox Add-ons][firefox] | Optional |
|
|
54
|
+
| Browser extension packages | [GitHub Releases] | Manual/dev installs and checksums |
|
|
55
|
+
|
|
56
|
+
## Screenshots
|
|
57
|
+
|
|
58
|
+
Query count, query duration, and application time:
|
|
59
|
+
|
|
60
|
+

|
|
61
|
+
|
|
62
|
+
Similar and duplicate queries with details:
|
|
63
|
+
|
|
64
|
+

|
|
65
|
+
|
|
66
|
+
The optional Chrome and Firefox extension shows query details in DevTools:
|
|
67
|
+
|
|
68
|
+
[](#browser-extension)
|
|
69
|
+
|
|
70
|
+
## Motivation
|
|
71
|
+
|
|
72
|
+
django-devbar sends metrics in response headers and can display an HTML bar.
|
|
73
|
+
Compared with [Django Debug Toolbar](https://django-debug-toolbar.readthedocs.io/):
|
|
74
|
+
|
|
75
|
+
- Setup requires one middleware entry.
|
|
76
|
+
- The browser extension reads metrics from any response type, including JSON.
|
|
77
|
+
- Django is the only dependency.
|
|
78
|
+
- Metrics require no extra requests to debug endpoints.
|
|
79
|
+
- The HTML bar is optional. You can use headers and the extension alone.
|
|
80
|
+
|
|
81
|
+
## Django setup
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
# Using uv
|
|
85
|
+
uv add --dev django-devbar
|
|
86
|
+
|
|
87
|
+
# Or using pip
|
|
88
|
+
pip install django-devbar
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Place DevBar near the start of your middleware list:
|
|
92
|
+
|
|
93
|
+
```python
|
|
94
|
+
MIDDLEWARE = [
|
|
95
|
+
"django.middleware.security.SecurityMiddleware",
|
|
96
|
+
# ...
|
|
97
|
+
]
|
|
98
|
+
|
|
99
|
+
if DEBUG:
|
|
100
|
+
idx = MIDDLEWARE.index("django.middleware.security.SecurityMiddleware")
|
|
101
|
+
MIDDLEWARE.insert(idx + 1, "django_devbar.DevBarMiddleware")
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
The `if DEBUG` condition keeps the middleware active only in development. It also
|
|
105
|
+
avoids import errors when the package is not installed in production.
|
|
106
|
+
|
|
107
|
+
If the middleware remains installed, `DEBUG=False` disables the HTML bar and detailed
|
|
108
|
+
`DevBar-Data` header by default, but query collection and `Server-Timing` remain active.
|
|
109
|
+
Use the conditional setup above to disable collection in production.
|
|
110
|
+
|
|
111
|
+
## Configuration
|
|
112
|
+
|
|
113
|
+
All settings are optional. Set them in a `DEVBAR` dictionary in your Django settings:
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
DEVBAR = {
|
|
117
|
+
"POSITION": "bottom-right", # bottom-right (default), bottom-left, top-right, top-left
|
|
118
|
+
"SHOW_BAR": None, # follows DEBUG; set True/False to override
|
|
119
|
+
"ENABLE_DEVTOOLS_DATA": None, # follows DEBUG; set True/False to override
|
|
120
|
+
"DEVTOOLS_HEADER_MAX_BYTES": 6144, # max bytes for DevBar-Data header payload
|
|
121
|
+
"DEVTOOLS_MAX_QUERIES": None, # optional cap for query entries sent to DevTools
|
|
122
|
+
}
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
Header limits reduce data sent to DevTools, not query collection or its memory use.
|
|
126
|
+
|
|
127
|
+
## Response headers
|
|
128
|
+
|
|
129
|
+
DevBar always adds `Server-Timing` with database, application, and total time.
|
|
130
|
+
You can view it in the browser's Network tab under Timing:
|
|
131
|
+
|
|
132
|
+
```
|
|
133
|
+
Server-Timing: db;dur=87.50, app;dur=41.30, total;dur=128.80
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Timings and query counts exclude streaming body generation and queries executed
|
|
137
|
+
while a streaming response is consumed.
|
|
138
|
+
|
|
139
|
+
With `DEBUG=True`, DevBar also adds a `DevBar-Data` JSON header by default:
|
|
140
|
+
|
|
141
|
+
- The `q` entries contain query details, with `dup` and `sim` flags for duplicate and similar queries.
|
|
142
|
+
- The payload is truncated to fit `DEVTOOLS_HEADER_MAX_BYTES`.
|
|
143
|
+
- Truncated payloads include `tr`, `q_total`, and `q_sent` metadata.
|
|
144
|
+
|
|
145
|
+
Use these headers to inspect API responses, read metrics in the browser extension,
|
|
146
|
+
or check query counts in automated tests.
|
|
147
|
+
|
|
148
|
+
## Browser extension
|
|
149
|
+
|
|
150
|
+
Install the extension from [Chrome Web Store][chrome] or [Firefox Add-ons][firefox]
|
|
151
|
+
to view metrics in DevTools.
|
|
152
|
+
|
|
153
|
+
See [browser-extension/README.md](browser-extension/README.md) for more details.
|
|
154
|
+
|
|
155
|
+
[badge chrome]: https://img.shields.io/chrome-web-store/v/fehcaaopchkbknbdhjadnmehiifdmeid?label=Chrome
|
|
156
|
+
[badge firefox]: https://img.shields.io/amo/v/django-devbar?label=Firefox
|
|
157
|
+
[badge pypi]: https://img.shields.io/pypi/v/django-devbar.svg
|
|
158
|
+
[chrome]: https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid
|
|
159
|
+
[firefox]: https://addons.mozilla.org/en-US/firefox/addon/django-devbar/
|
|
160
|
+
[github releases]: https://github.com/amureki/django-devbar/releases
|
|
161
|
+
[pypi]: https://pypi.org/project/django-devbar/
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# django-devbar
|
|
2
|
+
|
|
3
|
+
A performance bar for Django development. Shows database query counts, query duration,
|
|
4
|
+
and application time. Flags similar and duplicate queries.
|
|
5
|
+
|
|
6
|
+
Settings and the response header format remain compatible within 1.x.
|
|
7
|
+
Breaking changes require a new major version.
|
|
8
|
+
|
|
9
|
+
[![Badge PyPI]][pypi]
|
|
10
|
+
[![Badge Chrome]][chrome]
|
|
11
|
+
[![Badge Firefox]][firefox]
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
| Component | Install from | Notes |
|
|
16
|
+
| :------------------------- | :------------------------- | :-------------------------------- |
|
|
17
|
+
| Django package | [PyPI] | `uv add --dev django-devbar` |
|
|
18
|
+
| Chrome DevTools extension | [Chrome Web Store][chrome] | Optional |
|
|
19
|
+
| Firefox DevTools extension | [Firefox Add-ons][firefox] | Optional |
|
|
20
|
+
| Browser extension packages | [GitHub Releases] | Manual/dev installs and checksums |
|
|
21
|
+
|
|
22
|
+
## Screenshots
|
|
23
|
+
|
|
24
|
+
Query count, query duration, and application time:
|
|
25
|
+
|
|
26
|
+

|
|
27
|
+
|
|
28
|
+
Similar and duplicate queries with details:
|
|
29
|
+
|
|
30
|
+

|
|
31
|
+
|
|
32
|
+
The optional Chrome and Firefox extension shows query details in DevTools:
|
|
33
|
+
|
|
34
|
+
[](#browser-extension)
|
|
35
|
+
|
|
36
|
+
## Motivation
|
|
37
|
+
|
|
38
|
+
django-devbar sends metrics in response headers and can display an HTML bar.
|
|
39
|
+
Compared with [Django Debug Toolbar](https://django-debug-toolbar.readthedocs.io/):
|
|
40
|
+
|
|
41
|
+
- Setup requires one middleware entry.
|
|
42
|
+
- The browser extension reads metrics from any response type, including JSON.
|
|
43
|
+
- Django is the only dependency.
|
|
44
|
+
- Metrics require no extra requests to debug endpoints.
|
|
45
|
+
- The HTML bar is optional. You can use headers and the extension alone.
|
|
46
|
+
|
|
47
|
+
## Django setup
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
# Using uv
|
|
51
|
+
uv add --dev django-devbar
|
|
52
|
+
|
|
53
|
+
# Or using pip
|
|
54
|
+
pip install django-devbar
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Place DevBar near the start of your middleware list:
|
|
58
|
+
|
|
59
|
+
```python
|
|
60
|
+
MIDDLEWARE = [
|
|
61
|
+
"django.middleware.security.SecurityMiddleware",
|
|
62
|
+
# ...
|
|
63
|
+
]
|
|
64
|
+
|
|
65
|
+
if DEBUG:
|
|
66
|
+
idx = MIDDLEWARE.index("django.middleware.security.SecurityMiddleware")
|
|
67
|
+
MIDDLEWARE.insert(idx + 1, "django_devbar.DevBarMiddleware")
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
The `if DEBUG` condition keeps the middleware active only in development. It also
|
|
71
|
+
avoids import errors when the package is not installed in production.
|
|
72
|
+
|
|
73
|
+
If the middleware remains installed, `DEBUG=False` disables the HTML bar and detailed
|
|
74
|
+
`DevBar-Data` header by default, but query collection and `Server-Timing` remain active.
|
|
75
|
+
Use the conditional setup above to disable collection in production.
|
|
76
|
+
|
|
77
|
+
## Configuration
|
|
78
|
+
|
|
79
|
+
All settings are optional. Set them in a `DEVBAR` dictionary in your Django settings:
|
|
80
|
+
|
|
81
|
+
```python
|
|
82
|
+
DEVBAR = {
|
|
83
|
+
"POSITION": "bottom-right", # bottom-right (default), bottom-left, top-right, top-left
|
|
84
|
+
"SHOW_BAR": None, # follows DEBUG; set True/False to override
|
|
85
|
+
"ENABLE_DEVTOOLS_DATA": None, # follows DEBUG; set True/False to override
|
|
86
|
+
"DEVTOOLS_HEADER_MAX_BYTES": 6144, # max bytes for DevBar-Data header payload
|
|
87
|
+
"DEVTOOLS_MAX_QUERIES": None, # optional cap for query entries sent to DevTools
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
Header limits reduce data sent to DevTools, not query collection or its memory use.
|
|
92
|
+
|
|
93
|
+
## Response headers
|
|
94
|
+
|
|
95
|
+
DevBar always adds `Server-Timing` with database, application, and total time.
|
|
96
|
+
You can view it in the browser's Network tab under Timing:
|
|
97
|
+
|
|
98
|
+
```
|
|
99
|
+
Server-Timing: db;dur=87.50, app;dur=41.30, total;dur=128.80
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
Timings and query counts exclude streaming body generation and queries executed
|
|
103
|
+
while a streaming response is consumed.
|
|
104
|
+
|
|
105
|
+
With `DEBUG=True`, DevBar also adds a `DevBar-Data` JSON header by default:
|
|
106
|
+
|
|
107
|
+
- The `q` entries contain query details, with `dup` and `sim` flags for duplicate and similar queries.
|
|
108
|
+
- The payload is truncated to fit `DEVTOOLS_HEADER_MAX_BYTES`.
|
|
109
|
+
- Truncated payloads include `tr`, `q_total`, and `q_sent` metadata.
|
|
110
|
+
|
|
111
|
+
Use these headers to inspect API responses, read metrics in the browser extension,
|
|
112
|
+
or check query counts in automated tests.
|
|
113
|
+
|
|
114
|
+
## Browser extension
|
|
115
|
+
|
|
116
|
+
Install the extension from [Chrome Web Store][chrome] or [Firefox Add-ons][firefox]
|
|
117
|
+
to view metrics in DevTools.
|
|
118
|
+
|
|
119
|
+
See [browser-extension/README.md](browser-extension/README.md) for more details.
|
|
120
|
+
|
|
121
|
+
[badge chrome]: https://img.shields.io/chrome-web-store/v/fehcaaopchkbknbdhjadnmehiifdmeid?label=Chrome
|
|
122
|
+
[badge firefox]: https://img.shields.io/amo/v/django-devbar?label=Firefox
|
|
123
|
+
[badge pypi]: https://img.shields.io/pypi/v/django-devbar.svg
|
|
124
|
+
[chrome]: https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid
|
|
125
|
+
[firefox]: https://addons.mozilla.org/en-US/firefox/addon/django-devbar/
|
|
126
|
+
[github releases]: https://github.com/amureki/django-devbar/releases
|
|
127
|
+
[pypi]: https://pypi.org/project/django-devbar/
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "django-devbar"
|
|
3
|
+
version = "1.0.0"
|
|
4
|
+
description = "Lightweight performance devbar for Django"
|
|
5
|
+
readme = "README.md"
|
|
6
|
+
license = "MIT"
|
|
7
|
+
requires-python = ">=3.10"
|
|
8
|
+
dependencies = ["django>=4.2"]
|
|
9
|
+
keywords = [
|
|
10
|
+
"django",
|
|
11
|
+
"debug",
|
|
12
|
+
"performance",
|
|
13
|
+
"monitoring",
|
|
14
|
+
"development",
|
|
15
|
+
]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 5 - Production/Stable",
|
|
18
|
+
"Programming Language :: Python",
|
|
19
|
+
"Programming Language :: Python :: 3",
|
|
20
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
21
|
+
"Programming Language :: Python :: 3.10",
|
|
22
|
+
"Programming Language :: Python :: 3.11",
|
|
23
|
+
"Programming Language :: Python :: 3.12",
|
|
24
|
+
"Programming Language :: Python :: 3.13",
|
|
25
|
+
"Programming Language :: Python :: 3.14",
|
|
26
|
+
"Framework :: Django",
|
|
27
|
+
"Framework :: Django :: 4.2",
|
|
28
|
+
"Framework :: Django :: 5.0",
|
|
29
|
+
"Framework :: Django :: 5.1",
|
|
30
|
+
"Framework :: Django :: 5.2",
|
|
31
|
+
"Framework :: Django :: 6.0",
|
|
32
|
+
"Topic :: Software Development",
|
|
33
|
+
"Intended Audience :: Developers",
|
|
34
|
+
"License :: OSI Approved :: MIT License",
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
[[project.authors]]
|
|
38
|
+
name = "amureki"
|
|
39
|
+
email = "oss@amureki.me"
|
|
40
|
+
|
|
41
|
+
[project.urls]
|
|
42
|
+
Homepage = "https://github.com/amureki/django-devbar"
|
|
43
|
+
Repository = "https://github.com/amureki/django-devbar"
|
|
44
|
+
Issues = "https://github.com/amureki/django-devbar/issues"
|
|
45
|
+
Funding = "https://github.com/sponsors/amureki"
|
|
46
|
+
|
|
47
|
+
[build-system]
|
|
48
|
+
requires = ["uv_build>=0.9.16,<0.10.0"]
|
|
49
|
+
build-backend = "uv_build"
|
|
50
|
+
|
|
51
|
+
[dependency-groups]
|
|
52
|
+
dev = [
|
|
53
|
+
"pytest",
|
|
54
|
+
"pytest-django",
|
|
55
|
+
"ruff",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
[tool.pytest]
|
|
59
|
+
pythonpath = [
|
|
60
|
+
"src",
|
|
61
|
+
".",
|
|
62
|
+
]
|
|
63
|
+
testpaths = ["tests"]
|
|
64
|
+
norecursedirs = [
|
|
65
|
+
".venv",
|
|
66
|
+
".git",
|
|
67
|
+
]
|
|
68
|
+
DJANGO_SETTINGS_MODULE = "tests.settings"
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "django-devbar"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "1.0.0"
|
|
4
4
|
description = "Lightweight performance devbar for Django"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
license = "MIT"
|
|
@@ -11,6 +11,7 @@ requires-python = ">=3.10"
|
|
|
11
11
|
dependencies = ["django>=4.2"]
|
|
12
12
|
keywords = ["django", "debug", "performance", "monitoring", "development"]
|
|
13
13
|
classifiers = [
|
|
14
|
+
"Development Status :: 5 - Production/Stable",
|
|
14
15
|
"Programming Language :: Python",
|
|
15
16
|
"Programming Language :: Python :: 3",
|
|
16
17
|
"Programming Language :: Python :: 3 :: Only",
|
|
@@ -34,6 +35,7 @@ classifiers = [
|
|
|
34
35
|
Homepage = "https://github.com/amureki/django-devbar"
|
|
35
36
|
Repository = "https://github.com/amureki/django-devbar"
|
|
36
37
|
Issues = "https://github.com/amureki/django-devbar/issues"
|
|
38
|
+
Funding = "https://github.com/sponsors/amureki"
|
|
37
39
|
|
|
38
40
|
[build-system]
|
|
39
41
|
requires = ["uv_build>=0.9.16,<0.10.0"]
|
|
@@ -165,6 +165,9 @@ class DevBarMiddleware:
|
|
|
165
165
|
f"app;dur={stats['python_time']:.2f}",
|
|
166
166
|
f"total;dur={stats['total_time']:.2f}",
|
|
167
167
|
]
|
|
168
|
+
existing = response.get("Server-Timing")
|
|
169
|
+
if existing:
|
|
170
|
+
parts.insert(0, existing)
|
|
168
171
|
response["Server-Timing"] = ", ".join(parts)
|
|
169
172
|
|
|
170
173
|
def _can_inject(self, response):
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import re
|
|
2
|
+
from collections.abc import Mapping
|
|
2
3
|
from contextvars import ContextVar
|
|
3
4
|
from time import perf_counter
|
|
4
5
|
|
|
@@ -28,26 +29,17 @@ def get_stats():
|
|
|
28
29
|
|
|
29
30
|
# Count occurrences of each SQL template and each (SQL, params_hash) pair
|
|
30
31
|
sql_counts = {}
|
|
31
|
-
|
|
32
|
+
dup_key_counts = {}
|
|
32
33
|
for q in queries:
|
|
33
34
|
sql = q["sql"]
|
|
34
35
|
params_hash = q["params_hash"]
|
|
35
36
|
sql_counts[sql] = sql_counts.get(sql, 0) + 1
|
|
36
37
|
dup_key = (sql, params_hash)
|
|
37
|
-
|
|
38
|
-
q["is_duplicate"] = True
|
|
39
|
-
else:
|
|
40
|
-
duplicate_keys.add(dup_key)
|
|
38
|
+
dup_key_counts[dup_key] = dup_key_counts.get(dup_key, 0) + 1
|
|
41
39
|
|
|
42
40
|
# Similar = SQL template appears 2+ times (matches DDT semantics)
|
|
43
41
|
similar_sqls = {sql for sql, count in sql_counts.items() if count > 1}
|
|
44
42
|
|
|
45
|
-
# Second pass: mark all queries in groups with 2+ members
|
|
46
|
-
dup_key_counts = {}
|
|
47
|
-
for q in queries:
|
|
48
|
-
dup_key = (q["sql"], q["params_hash"])
|
|
49
|
-
dup_key_counts[dup_key] = dup_key_counts.get(dup_key, 0) + 1
|
|
50
|
-
|
|
51
43
|
duplicate_keys_final = {k for k, count in dup_key_counts.items() if count > 1}
|
|
52
44
|
|
|
53
45
|
similar_queries = []
|
|
@@ -70,6 +62,8 @@ def get_stats():
|
|
|
70
62
|
|
|
71
63
|
|
|
72
64
|
def _hash_params(params):
|
|
65
|
+
if isinstance(params, Mapping):
|
|
66
|
+
params = tuple(sorted(params.items()))
|
|
73
67
|
try:
|
|
74
68
|
return hash(tuple(params)) if params else 0
|
|
75
69
|
except TypeError:
|
django_devbar-0.7.0/PKG-INFO
DELETED
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.4
|
|
2
|
-
Name: django-devbar
|
|
3
|
-
Version: 0.7.0
|
|
4
|
-
Summary: Lightweight performance devbar for Django
|
|
5
|
-
Keywords: django,debug,performance,monitoring,development
|
|
6
|
-
Author: amureki
|
|
7
|
-
Author-email: amureki <oss@amureki.me>
|
|
8
|
-
License-Expression: MIT
|
|
9
|
-
Classifier: Programming Language :: Python
|
|
10
|
-
Classifier: Programming Language :: Python :: 3
|
|
11
|
-
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
13
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
14
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
15
|
-
Classifier: Programming Language :: Python :: 3.13
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.14
|
|
17
|
-
Classifier: Framework :: Django
|
|
18
|
-
Classifier: Framework :: Django :: 4.2
|
|
19
|
-
Classifier: Framework :: Django :: 5.0
|
|
20
|
-
Classifier: Framework :: Django :: 5.1
|
|
21
|
-
Classifier: Framework :: Django :: 5.2
|
|
22
|
-
Classifier: Framework :: Django :: 6.0
|
|
23
|
-
Classifier: Topic :: Software Development
|
|
24
|
-
Classifier: Intended Audience :: Developers
|
|
25
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
26
|
-
Requires-Dist: django>=4.2
|
|
27
|
-
Requires-Python: >=3.10
|
|
28
|
-
Project-URL: Homepage, https://github.com/amureki/django-devbar
|
|
29
|
-
Project-URL: Repository, https://github.com/amureki/django-devbar
|
|
30
|
-
Project-URL: Issues, https://github.com/amureki/django-devbar/issues
|
|
31
|
-
Description-Content-Type: text/markdown
|
|
32
|
-
|
|
33
|
-
# django-devbar
|
|
34
|
-
|
|
35
|
-
> [!WARNING]
|
|
36
|
-
> This package is experimental and may introduce breaking changes in minor versions.
|
|
37
|
-
|
|
38
|
-
Lightweight performance devbar for Django.
|
|
39
|
-
Shows DB query count, query duration, application time, and detects similar and duplicate queries with visual severity indicators.
|
|
40
|
-
|
|
41
|
-
## Showcase
|
|
42
|
-
|
|
43
|
-
Normal operation – showing query count, duration, and application time:
|
|
44
|
-
|
|
45
|
-

|
|
46
|
-
|
|
47
|
-
Similar and duplicate queries detected – severity indicators and details shown:
|
|
48
|
-
|
|
49
|
-

|
|
50
|
-
|
|
51
|
-
[optional] Chrome extension - showing detailed metrics in DevTools panel:
|
|
52
|
-
|
|
53
|
-
[](#chrome-extension)
|
|
54
|
-
|
|
55
|
-
## Motivation
|
|
56
|
-
|
|
57
|
-
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:
|
|
58
|
-
|
|
59
|
-
- **Minimal setup** — just add middleware, nothing else required
|
|
60
|
-
- **Browser DevTools integration** — Chrome extension panel works with any response type, including JSON
|
|
61
|
-
- **Zero extra dependencies** — only requires Django
|
|
62
|
-
- **Lower overhead** — no extra requests to debug endpoints
|
|
63
|
-
- **Non-intrusive** — HTML bar is optional; works via headers and DevTools panel alone
|
|
64
|
-
|
|
65
|
-
## Installation
|
|
66
|
-
|
|
67
|
-
```bash
|
|
68
|
-
# Using uv (recommended)
|
|
69
|
-
uv add --dev django-devbar
|
|
70
|
-
|
|
71
|
-
# Or using pip
|
|
72
|
-
pip install django-devbar
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
Add to your middleware early. For example:
|
|
76
|
-
|
|
77
|
-
```python
|
|
78
|
-
MIDDLEWARE = [
|
|
79
|
-
"django.middleware.security.SecurityMiddleware",
|
|
80
|
-
# ...
|
|
81
|
-
]
|
|
82
|
-
|
|
83
|
-
if DEBUG:
|
|
84
|
-
idx = MIDDLEWARE.index("django.middleware.security.SecurityMiddleware")
|
|
85
|
-
MIDDLEWARE.insert(idx + 1, "django_devbar.DevBarMiddleware")
|
|
86
|
-
```
|
|
87
|
-
|
|
88
|
-
This keeps the middleware active only in development and avoids import errors if the package isn't installed in production.
|
|
89
|
-
|
|
90
|
-
## Configuration
|
|
91
|
-
|
|
92
|
-
All settings are optional. Configure via a `DEVBAR` dict in your Django settings:
|
|
93
|
-
|
|
94
|
-
```python
|
|
95
|
-
DEVBAR = {
|
|
96
|
-
"POSITION": "bottom-right", # bottom-right (default), bottom-left, top-right, top-left
|
|
97
|
-
"SHOW_BAR": None, # follows DEBUG; set True/False to override
|
|
98
|
-
"ENABLE_DEVTOOLS_DATA": None, # follows DEBUG; set True/False to override
|
|
99
|
-
"DEVTOOLS_HEADER_MAX_BYTES": 6144, # max bytes for DevBar-Data header payload
|
|
100
|
-
"DEVTOOLS_MAX_QUERIES": None, # optional hard cap for q/dup entries sent to DevTools
|
|
101
|
-
}
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
## Response Headers
|
|
105
|
-
|
|
106
|
-
Django DevBar adds HTTP response headers with performance metrics:
|
|
107
|
-
|
|
108
|
-
- **Server-Timing** (always present) – Standard HTTP header with database, application, and total time metrics. Visible in Chrome DevTools Network tab under Timing.
|
|
109
|
-
|
|
110
|
-
An additional header is included by default in DEBUG mode:
|
|
111
|
-
|
|
112
|
-
- **DevBar-Data** - JSON header with comprehensive metrics including similar and duplicate query details
|
|
113
|
-
- Query-level flags are embedded in `q` entries (`dup` and `sim`)
|
|
114
|
-
- Payload is automatically truncated to fit `DEVTOOLS_HEADER_MAX_BYTES`
|
|
115
|
-
- When truncated, response includes metadata keys: `tr`, `q_total`, `q_sent`
|
|
116
|
-
|
|
117
|
-
This is useful for:
|
|
118
|
-
|
|
119
|
-
- **API endpoints** where the HTML overlay can't be displayed
|
|
120
|
-
- **Automated testing** to assert performance metrics (e.g., fail CI if query count exceeds a limit)
|
|
121
|
-
- **Browser extensions** that need detailed duplicate query information
|
|
122
|
-
|
|
123
|
-
### Server-Timing format
|
|
124
|
-
|
|
125
|
-
```
|
|
126
|
-
Server-Timing: db;dur=87.50, app;dur=41.30, total;dur=128.80
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
## Chrome Extension
|
|
130
|
-
|
|
131
|
-
View Django DevBar metrics directly in Chrome DevTools with the [official extension](https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid).
|
|
132
|
-
|
|
133
|
-
See [chrome-extension/README.md](chrome-extension/README.md) for more details.
|
django_devbar-0.7.0/README.md
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
# django-devbar
|
|
2
|
-
|
|
3
|
-
> [!WARNING]
|
|
4
|
-
> This package is experimental and may introduce breaking changes in minor versions.
|
|
5
|
-
|
|
6
|
-
Lightweight performance devbar for Django.
|
|
7
|
-
Shows DB query count, query duration, application time, and detects similar and duplicate queries with visual severity indicators.
|
|
8
|
-
|
|
9
|
-
## Showcase
|
|
10
|
-
|
|
11
|
-
Normal operation – showing query count, duration, and application time:
|
|
12
|
-
|
|
13
|
-

|
|
14
|
-
|
|
15
|
-
Similar and duplicate queries detected – severity indicators and details shown:
|
|
16
|
-
|
|
17
|
-

|
|
18
|
-
|
|
19
|
-
[optional] Chrome extension - showing detailed metrics in DevTools panel:
|
|
20
|
-
|
|
21
|
-
[](#chrome-extension)
|
|
22
|
-
|
|
23
|
-
## Motivation
|
|
24
|
-
|
|
25
|
-
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:
|
|
26
|
-
|
|
27
|
-
- **Minimal setup** — just add middleware, nothing else required
|
|
28
|
-
- **Browser DevTools integration** — Chrome extension panel works with any response type, including JSON
|
|
29
|
-
- **Zero extra dependencies** — only requires Django
|
|
30
|
-
- **Lower overhead** — no extra requests to debug endpoints
|
|
31
|
-
- **Non-intrusive** — HTML bar is optional; works via headers and DevTools panel alone
|
|
32
|
-
|
|
33
|
-
## Installation
|
|
34
|
-
|
|
35
|
-
```bash
|
|
36
|
-
# Using uv (recommended)
|
|
37
|
-
uv add --dev django-devbar
|
|
38
|
-
|
|
39
|
-
# Or using pip
|
|
40
|
-
pip install django-devbar
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Add to your middleware early. For example:
|
|
44
|
-
|
|
45
|
-
```python
|
|
46
|
-
MIDDLEWARE = [
|
|
47
|
-
"django.middleware.security.SecurityMiddleware",
|
|
48
|
-
# ...
|
|
49
|
-
]
|
|
50
|
-
|
|
51
|
-
if DEBUG:
|
|
52
|
-
idx = MIDDLEWARE.index("django.middleware.security.SecurityMiddleware")
|
|
53
|
-
MIDDLEWARE.insert(idx + 1, "django_devbar.DevBarMiddleware")
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
This keeps the middleware active only in development and avoids import errors if the package isn't installed in production.
|
|
57
|
-
|
|
58
|
-
## Configuration
|
|
59
|
-
|
|
60
|
-
All settings are optional. Configure via a `DEVBAR` dict in your Django settings:
|
|
61
|
-
|
|
62
|
-
```python
|
|
63
|
-
DEVBAR = {
|
|
64
|
-
"POSITION": "bottom-right", # bottom-right (default), bottom-left, top-right, top-left
|
|
65
|
-
"SHOW_BAR": None, # follows DEBUG; set True/False to override
|
|
66
|
-
"ENABLE_DEVTOOLS_DATA": None, # follows DEBUG; set True/False to override
|
|
67
|
-
"DEVTOOLS_HEADER_MAX_BYTES": 6144, # max bytes for DevBar-Data header payload
|
|
68
|
-
"DEVTOOLS_MAX_QUERIES": None, # optional hard cap for q/dup entries sent to DevTools
|
|
69
|
-
}
|
|
70
|
-
```
|
|
71
|
-
|
|
72
|
-
## Response Headers
|
|
73
|
-
|
|
74
|
-
Django DevBar adds HTTP response headers with performance metrics:
|
|
75
|
-
|
|
76
|
-
- **Server-Timing** (always present) – Standard HTTP header with database, application, and total time metrics. Visible in Chrome DevTools Network tab under Timing.
|
|
77
|
-
|
|
78
|
-
An additional header is included by default in DEBUG mode:
|
|
79
|
-
|
|
80
|
-
- **DevBar-Data** - JSON header with comprehensive metrics including similar and duplicate query details
|
|
81
|
-
- Query-level flags are embedded in `q` entries (`dup` and `sim`)
|
|
82
|
-
- Payload is automatically truncated to fit `DEVTOOLS_HEADER_MAX_BYTES`
|
|
83
|
-
- When truncated, response includes metadata keys: `tr`, `q_total`, `q_sent`
|
|
84
|
-
|
|
85
|
-
This is useful for:
|
|
86
|
-
|
|
87
|
-
- **API endpoints** where the HTML overlay can't be displayed
|
|
88
|
-
- **Automated testing** to assert performance metrics (e.g., fail CI if query count exceeds a limit)
|
|
89
|
-
- **Browser extensions** that need detailed duplicate query information
|
|
90
|
-
|
|
91
|
-
### Server-Timing format
|
|
92
|
-
|
|
93
|
-
```
|
|
94
|
-
Server-Timing: db;dur=87.50, app;dur=41.30, total;dur=128.80
|
|
95
|
-
```
|
|
96
|
-
|
|
97
|
-
## Chrome Extension
|
|
98
|
-
|
|
99
|
-
View Django DevBar metrics directly in Chrome DevTools with the [official extension](https://chromewebstore.google.com/detail/django-devbar/fehcaaopchkbknbdhjadnmehiifdmeid).
|
|
100
|
-
|
|
101
|
-
See [chrome-extension/README.md](chrome-extension/README.md) for more details.
|
|
File without changes
|
|
File without changes
|
{django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/templates/django_devbar/devbar.html
RENAMED
|
File without changes
|
|
File without changes
|
{django_devbar-0.7.0 → django_devbar-1.0.0}/src/django_devbar/templates/django_devbar/similar.html
RENAMED
|
File without changes
|