aboutsummaryrefslogtreecommitdiffstats
path: root/rest_framework/views.py
diff options
context:
space:
mode:
authorTom Christie2014-09-11 13:20:44 +0100
committerTom Christie2014-09-11 13:20:44 +0100
commitde301f3b6647e1c79a506405a88071ef977418d1 (patch)
tree407f3497b422f334b47088b0bb35d39a8a3a520a /rest_framework/views.py
parent80ba0473473501968154c5cc5dd5922e53d96a70 (diff)
parent015a8122c7738dd8913939b42d3f0ec932d88711 (diff)
downloaddjango-rest-framework-de301f3b6647e1c79a506405a88071ef977418d1.tar.bz2
Merge master
Diffstat (limited to 'rest_framework/views.py')
-rw-r--r--rest_framework/views.py10
1 files changed, 6 insertions, 4 deletions
diff --git a/rest_framework/views.py b/rest_framework/views.py
index 079e9285..3b7b1c16 100644
--- a/rest_framework/views.py
+++ b/rest_framework/views.py
@@ -108,7 +108,9 @@ class APIView(View):
"""
view = super(APIView, cls).as_view(**initkwargs)
view.cls = cls
- return view
+ # Note: session based authentication is explicitly CSRF validated,
+ # all other authentication is CSRF exempt.
+ return csrf_exempt(view)
@property
def allowed_methods(self):
@@ -376,9 +378,9 @@ class APIView(View):
response.exception = True
return response
- # Note: session based authentication is explicitly CSRF validated,
- # all other authentication is CSRF exempt.
- @csrf_exempt
+ # Note: Views are made CSRF exempt from within `as_view` as to prevent
+ # accidental removal of this exemption in cases where `dispatch` needs to
+ # be overridden.
def dispatch(self, request, *args, **kwargs):
"""
`.dispatch()` is pretty much the same as Django's regular dispatch,