[PATCH 07/19] settings: Use 'MIDDLEWARE' for Django >= 1.10
Stephen Finucane
stephen at that.guru
Thu May 11 05:45:16 AEST 2017
This raises warnings in Django 1.10 and will be mandatory in Django 2.0.
Signed-off-by: Stephen Finucane <stephen at that.guru>
---
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 d82c41d..8776a5e 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 86b0f1b..26d3e83 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.9.3
More information about the Patchwork
mailing list