fixed debugtool middleware be after GZip middleware (#12443)
Fix django-debug-toolbar middleware be after GZip middleware
This commit is contained in:
Родитель
b762aeb21b
Коммит
9cf0ac5b43
15
settings.py
15
settings.py
|
@ -19,7 +19,20 @@ INSTALLED_APPS += (
|
|||
'debug_toolbar',
|
||||
)
|
||||
|
||||
MIDDLEWARE = ('debug_toolbar.middleware.DebugToolbarMiddleware',) + MIDDLEWARE
|
||||
# django-debug-doolbar middleware needs to be inserted as high as possible
|
||||
# but after GZip middleware
|
||||
def insert_debug_toolbar_middleware(middlewares):
|
||||
ret_middleware = list(middlewares)
|
||||
|
||||
for i, middleware in enumerate(ret_middleware):
|
||||
if 'GZipMiddleware' in middleware:
|
||||
ret_middleware.insert(
|
||||
i + 1, 'debug_toolbar.middleware.DebugToolbarMiddleware')
|
||||
break
|
||||
|
||||
return tuple(ret_middleware)
|
||||
|
||||
MIDDLEWARE = insert_debug_toolbar_middleware(MIDDLEWARE)
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
# Enable django-debug-toolbar locally, if DEBUG is True.
|
||||
|
|
Загрузка…
Ссылка в новой задаче