Skip to content
Tags

Django 1.2.1 – CSRF verification failed – 403 Error

by admin on June 8th, 2010

Here is the kind of error you can get while attempting to make a POST request after migrating to Django 1.2.1:

403 Forbidden
CSRF verification failed. Request aborted.
Help

Reason given for failure:
CSRF cookie not set.

To correct this, all you have to do is to add  ‘django.middleware.csrf.CsrfViewMiddleware’, and ‘django.middleware.csrf.CsrfResponseMiddleware’ to your MIDDLEWARE_CLASSES in your settings.py file.

MIDDLEWARE_CLASSES = (
...
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
...
)

From → Tips

No comments yet

Leave a Reply

Note: XHTML is allowed. Your email address will never be published.

Subscribe to this comment feed via RSS