[Fixed]-Forbidden (403) CSRF verification failed. Request aborted 2 in django 1.8.5

1👍

To solve (403) CSRF verification error, you need to update your csrf toke in the request context each time that you render the form:

So add these to your both GET and POST methods

context_dict.update(csrf(request))

And don’t forget to import csrf at top of your views:

from django.views.decorators.csrf import csrf_protect

If you still have problem in processing the form, consider using ModelForms which is recommended and more robust way of processing forms in django.

👤qliq

Leave a comment