Answer the question
In order to leave comments, you need to log in
How to disable CSRF validation in django?
There is a class base view, I try to send a post request from another server, I get 403
Before the class, I connected a decorator to disable the check:
@method_decorator(csrf_exempt, name='dispatch')
class Example(TemplateView):
template_name = 'example.html'
def post(self, request, *args, **kwargs):
context = self.get_context_data()
print(request.POST)
return super(TemplateView, self).render_to_response(context)
Answer the question
In order to leave comments, you need to log in
Thank you all for your participation, I did it through the dispatch redefinition
@method_decorator(csrf_exempt)
def dispatch(self, request, *args, **kwargs):
return super(Example, self).dispatch(request, *args, **kwargs)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question