Django 1.2.1 – CSRF verification failed – 403 Error
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',
...
)