I was getting this 403 error today while attempting to make a POST request to a view:
403 Forbidden
CSRF verification failed. Request aborted.
Help
Reason given for failure:
CSRF cookie not set.
Hopefully this saves you some time because I sure wasted a lot of mine solving it. I ended up having to add ‘django.middleware.csrf.CsrfViewMiddleware’, and ‘django.middleware.csrf.CsrfResponseMiddleware’ to my MIDDLEWARE_CLASSES in settings.py and my problems were solved. All I had to say was mutha eff. Django also was no help with their debug. My MIDDLEWARE_CLASSES now looks like:
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
Hope this helps.




Herman | 01-Jun-10 at 6:02 am | Permalink
Thx bro… keep writing ….
Javi | 06-Jun-10 at 7:15 am | Permalink
Thank you, you centainly saved me a lot of time
Andy C | 22-Jun-10 at 5:57 am | Permalink
As a Django newcomer in the final throws of trying to get Django-Mingus working on Bluehost, a thousand thank yous. With this fix, my Admin dashboard is now fucntional. Hurrah !
Ralf W | 24-Jun-10 at 2:03 pm | Permalink
You sure saved my day. Thanks a lot!
xiaojay@gmail.com | 05-Jul-10 at 3:45 am | Permalink
谢谢你
thank u from china
adresc | 14-Jul-10 at 11:48 pm | Permalink
thanks man, also save my life
vader | 18-Jul-10 at 12:26 pm | Permalink
Muito Obrigado
Thank you from Brazil
Ro | 18-Aug-10 at 7:09 pm | Permalink
Thx from Russia
Very damn helpfull!
Gbolahan Oshonubi | 23-Aug-10 at 3:54 am | Permalink
Hello,
I have a similar challenge but upon trying to add the middleware there is to no change. Is there anything else I need to do? The changes I made were to these directory /usr/lib/python2.6/site-packages/Django-1.2.1-py2.6.egg/django/conf/project_template/settings.py
Is there any other directory I need to get thing changed apart from this.
I will really appreciate your immediate response.
Michael Heumann | 23-Aug-10 at 7:58 pm | Permalink
Thanks from Germany…
Just stumbled about this error and your posted solution.
BTW: Obviously this does not affect the devserver…
Chihyao | 28-Aug-10 at 11:42 am | Permalink
A big THANK YOU from Taiwan =]
Chanik Jo | 29-Aug-10 at 8:51 pm | Permalink
고맙습니다.
Thanks from Korea
Emil Stanchev | 30-Aug-10 at 4:21 pm | Permalink
Gbolahan, you need to edit the settings.py in your project, not the template project one.
richW | 31-Aug-10 at 11:19 am | Permalink
redundant but THANKS, I had the same issue and considered pushing my version back to 1.1. Saved me a ton of time.
Hadi Moshayedi | 03-Sep-10 at 10:25 am | Permalink
Thanks from Iran!
sergn | 03-Sep-10 at 3:01 pm | Permalink
Thanks from Ukraine!