summaryrefslogtreecommitdiff
path: root/django
diff options
context:
space:
mode:
Diffstat (limited to 'django')
-rw-r--r--django/middleware/csrf.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py
index 9ca727fca9..10fab290c9 100644
--- a/django/middleware/csrf.py
+++ b/django/middleware/csrf.py
@@ -62,9 +62,6 @@ class CsrfViewMiddleware(object):
tag.
"""
def process_view(self, request, callback, callback_args, callback_kwargs):
- if getattr(callback, 'csrf_exempt', False):
- return None
-
if getattr(request, 'csrf_processing_done', False):
return None
@@ -90,6 +87,11 @@ class CsrfViewMiddleware(object):
# place of a CSRF cookie for this request only.
cookie_is_new = True
+ # Wait until request.META["CSRF_COOKIE"] has been manipulated before
+ # bailing out, so that get_token still works
+ if getattr(callback, 'csrf_exempt', False):
+ return None
+
if request.method == 'POST':
if getattr(request, '_dont_enforce_csrf_checks', False):
# Mechanism to turn off CSRF checks for test suite. It comes after