fixed debugtool middleware be after GZip middleware (#12443)

Fix django-debug-toolbar middleware be after GZip middleware
This commit is contained in:
MyeongJun Go 2019-10-07 22:33:49 +09:00 коммит произвёл Mathieu Pillard
Родитель b762aeb21b
Коммит 9cf0ac5b43
1 изменённых файлов: 14 добавлений и 1 удалений

Просмотреть файл

@ -19,7 +19,20 @@ INSTALLED_APPS += (
'debug_toolbar', '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 = { DEBUG_TOOLBAR_CONFIG = {
# Enable django-debug-toolbar locally, if DEBUG is True. # Enable django-debug-toolbar locally, if DEBUG is True.