From e5adadaefcd5d30a69d343f7404bb21410ae8414 Mon Sep 17 00:00:00 2001 From: Jaap Roes Date: Thu, 16 Mar 2017 15:58:01 +0100 Subject: [PATCH] Use the newer MIDDLEWARE setting but fall back to MIDDLEWARE_CLASSES on Django < 1.10 --- sample_project/sample_project/settings.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sample_project/sample_project/settings.py b/sample_project/sample_project/settings.py index 9fabb27..7327e75 100644 --- a/sample_project/sample_project/settings.py +++ b/sample_project/sample_project/settings.py @@ -1,6 +1,8 @@ # Django settings for test_project project. import os +import django + def map_path(directory_name): return os.path.join(os.path.dirname(__file__), @@ -90,15 +92,19 @@ STATICFILES_FINDERS = ( # Make this unique, and don't share it with anybody. SECRET_KEY = '8**a!c8$1x)p@j2pj0yq!*v+dzp24g*$918ws#x@k+gf%0%rct' -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = [ 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', + 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', # Uncomment the next line for simple clickjacking protection: 'django.middleware.clickjacking.XFrameOptionsMiddleware', -) +] + +if django.VERSION < (1, 10): + MIDDLEWARE_CLASSES = MIDDLEWARE ROOT_URLCONF = 'sample_project.urls'