From 1399596de4b10a00c23d6ef3080f224fb99aba04 Mon Sep 17 00:00:00 2001 From: Stephen Finucane Date: Thu, 18 May 2017 21:17:44 +0100 Subject: [PATCH] settings: Use 'MIDDLEWARE' for Django >= 1.10 This raises warnings in Django 1.10 and will be mandatory in Django 2.0. Signed-off-by: Stephen Finucane --- patchwork/settings/base.py | 13 +++++++++---- patchwork/settings/dev.py | 11 ++++++++--- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/patchwork/settings/base.py b/patchwork/settings/base.py index d82c41d4..8776a5ed 100644 --- a/patchwork/settings/base.py +++ b/patchwork/settings/base.py @@ -26,7 +26,7 @@ INSTALLED_APPS = [ 'patchwork', ] -MIDDLEWARE_CLASSES = [ +_MIDDLEWARE_CLASSES = [ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', @@ -35,16 +35,21 @@ MIDDLEWARE_CLASSES = [ ] if django.VERSION >= (1, 7): - MIDDLEWARE_CLASSES += [ + _MIDDLEWARE_CLASSES += [ 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', ] if django.VERSION >= (1, 7): - MIDDLEWARE_CLASSES += [ + _MIDDLEWARE_CLASSES += [ 'django.contrib.admindocs.middleware.XViewMiddleware' ] else: - MIDDLEWARE_CLASSES += ['django.middleware.doc.XViewMiddleware'] + _MIDDLEWARE_CLASSES += ['django.middleware.doc.XViewMiddleware'] + +if django.VERSION >= (1, 10): + MIDDLEWARE = _MIDDLEWARE_CLASSES +else: + MIDDLEWARE_CLASSES = _MIDDLEWARE_CLASSES TIME_ZONE = 'Australia/Canberra' diff --git a/patchwork/settings/dev.py b/patchwork/settings/dev.py index 86b0f1b2..26d3e830 100644 --- a/patchwork/settings/dev.py +++ b/patchwork/settings/dev.py @@ -76,9 +76,14 @@ if django.VERSION >= (1, 8): DEBUG_TOOLBAR_PATCH_SETTINGS = False # This should go first in the middleware classes - MIDDLEWARE_CLASSES = [ - 'debug_toolbar.middleware.DebugToolbarMiddleware', - ] + MIDDLEWARE_CLASSES + if django.VERSION >= (1, 10): + MIDDLEWARE = [ + 'debug_toolbar.middleware.DebugToolbarMiddleware', + ] + MIDDLEWARE + else: + MIDDLEWARE_CLASSES = [ + 'debug_toolbar.middleware.DebugToolbarMiddleware', + ] + MIDDLEWARE_CLASSES INTERNAL_IPS = [ '127.0.0.1', '::1', -- 2.47.3