3👍
✅
You should split your production and local settings to different files, then in your local settings you would just add your middleware. Small example to get you started:
File structure:
Settings
---> __init__.py
---> prod.py
---> dev.py
Example how to add django_debug_toolbar only in dev.py settings:
__init__.py:
# Other settings ommitted
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
dev.py:
from settings import *
# Other settings ommitted
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
Source:stackexchange.com