Where do I put Django Debug Terminal in middleware
Django Debug Terminal's documentation says
The order of MIDDLEWARE is important. You should include the Debug Toolbar middleware as early as possible in the list. However, it must come after any other middleware that encodes the response’s content, such as GZipMiddleware.
But this can be a bit tricky. For example, in my settings.py I have
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.middleware.common.CommonMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
]
In this situation is the best place to put debug_toolbar.middleware.DebugToolbarMiddleware
right after django.middleware.common.CommonMiddleware
since that uses force_text
while AuthenticationMiddleware
, SessionMiddleware
and MessageMiddleware
don't seem to encode anything?