Using Django 1.4, and trying to save some data by using POST method from a html form and getting the below error message:
403 Forbidden
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF cookie not set.
Then need to remove all the entries from MIDDLEWARE_CLASSES which has “csrf” from the settings.py file. By default the MIDDLEWARE_CLASSES would be like below:
MIDDLEWARE_CLASSES = (
‘django.middleware.common.CommonMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
‘django.middleware.csrf.CsrfViewMiddleware’,
)
After removing all “csrf” entries, it will look as below:
MIDDLEWARE_CLASSES = (
‘django.middleware.common.CommonMiddleware’,
‘django.contrib.sessions.middleware.SessionMiddleware’,
‘django.contrib.auth.middleware.AuthenticationMiddleware’,
)