Commit a40b0a0d by Anthony Lenton

Added a try/except block when importing csrf decorator.

Made settings in the example_consumer conditional.
parent 4da68a58
......@@ -40,7 +40,10 @@ from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
from django.template import RequestContext
from django.template.loader import render_to_string
from django.views.decorators.csrf import csrf_exempt
try:
from django.views.decorators.csrf import csrf_exempt
except ImportError:
from django.contrib.csrf.middleware import csrf_exempt
from openid.consumer.consumer import (
Consumer, SUCCESS, CANCEL, FAILURE)
......
......@@ -86,11 +86,17 @@ TEMPLATE_LOADERS = (
# 'django.template.loaders.eggs.load_template_source',
)
import django
if float(django.get_version()[:3]) < 1.2:
csrf_middleware = 'django.contrib.csrf.middleware.CsrfViewMiddleware'
else:
csrf_middleware = 'django.middleware.csrf.CsrfViewMiddleware'
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
csrf_middleware,
)
ROOT_URLCONF = 'example_consumer.urls'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment