Skip to content

Commit 7ec1b3f

Browse files
committed
Clarify installation instructions
1 parent 39b2868 commit 7ec1b3f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

README.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,21 @@ uv add --dev django-devbar
4040
pip install django-devbar
4141
```
4242

43-
Add to your middleware as early as possible, but after any middleware that encodes the response (e.g., `GZipMiddleware`):
43+
Add to your middleware early. For example:
4444

4545
```python
4646
MIDDLEWARE = [
4747
"django.middleware.security.SecurityMiddleware",
48-
"django_devbar.DevBarMiddleware",
4948
# ...
5049
]
50+
51+
if DEBUG:
52+
idx = MIDDLEWARE.index("django.middleware.security.SecurityMiddleware")
53+
MIDDLEWARE.insert(idx + 1, "django_devbar.DevBarMiddleware")
5154
```
5255

56+
This keeps the middleware active only in development and avoids import errors if the package isn't installed in production.
57+
5358
## Configuration
5459

5560
All settings are optional. Configure via a `DEVBAR` dict in your Django settings:

0 commit comments

Comments
 (0)