Django: CSRF verification failed. Request aborted.
I just recently upgraded to Django v1.2.3. I'm really diggin' this new version so far. The framework has significantly matured now. There were no major problems with porting my existing sites except when I went into the CMS, would make an edit and then tried to save any changes to the db and I would get the following error message: "CSRF verification failed. Request aborted." I had NEVER seen that error before and no idea what to do. As with most things related to Django, (and really almost all open source projects), there was no documentation on this error. Not in the release notes. Not in the online documentation. Nowhere! I was foreseeing a long night ahead of me trying to get to the bottom of this error. So after some digging around I came across this blog entry from Jordan Messina that solved it for me. I sharing the solution here.
Simply edit your settings.py file and add the following lines to the MIDDLEWARE_CLASSES section:
'django.middleware.csrf.CsrfViewMiddleware',
'django.middleware.csrf.CsrfResponseMiddleware',
So it should now look like this:
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',
)
Kill the server. (If it's running.)
Run "syncdb".
Run the server and voila... when you save all should be good with the world. This saved me hours of my life. (Your mileage may vary.)