File tree Expand file tree Collapse file tree 1 file changed +7
-2
lines changed
Expand file tree Collapse file tree 1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -40,16 +40,21 @@ uv add --dev django-devbar
4040pip 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
4646MIDDLEWARE = [
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
5560All settings are optional. Configure via a ` DEVBAR ` dict in your Django settings:
You can’t perform that action at this time.
0 commit comments