Josh Crompton

How to turn off CSRF protection for class based views

It's gotta go on the .dispatch() method, not on .post() (or .get()).

class AwesomeView(DetailView):

    @method_decorator(csrf_exempt)
    def dispatch(self, *args, **kwargs):
        return super(AwesomeView, self).dispatch(*args, **kwargs)

    def post(self, request, *args, **kwargs):
        print request.POST
        return HttpResponse('Aw yeah!')