Get CSRF middleware to work on django 1.1- and 1.2+

This commit is contained in:
Martin Green 2011-05-02 02:51:14 +01:00
parent 9becad0d9a
commit 925ed4635b

View File

@ -1,6 +1,7 @@
from localsettings import * #inital localsettings call so that urljoins work
import os
import urlparse
import django
# Django settings for troggle project.
DEBUG = True
@ -58,12 +59,17 @@ TEMPLATE_CONTEXT_PROCESSORS = ( "django.core.context_processors.auth", "core.con
LOGIN_REDIRECT_URL = '/'
if django.VERSION[0] >=1 and django.VERSION[1] > 1:
csrfmiddleware = 'django.middleware.csrf.CsrfViewMiddleware'
else:
csrfmiddleware = 'django.contrib.csrf.middleware.CsrfMiddleware'
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
csrfmiddleware,
'troggle.middleware.SmartAppendSlashMiddleware'
)