I just got this error when trying to execute a Django application locally. A quick search on the web revealed that I needed to include the following two lines:
'django.middleware.csrf.CsrfViewMiddleware' 'django.middleware.csrf.CsrfResponseMiddleware'
in the ‘MIDDLEWARE_CLASSES’ setting in the Settings.py of the application.
In my setup ‘django.middleware.csrf.CsrfViewMiddleware’ class path was already there, but ‘django.middleware.csrf.CsrfResponseMiddleware’ path was not. I added the latter and it seemed to have resolved the error.
I’m not completely sure what these classes do in detail, but it appears to revolve around security related to the local developing environment and obviously cross-site forgery. I also noticed in the ‘django.middleware.csrf.CsrfResponseMiddleware’ class there are notes that the class was deprecated as of Django 1.4. Once I saw this I removed the path from my Settings.py file, re-ran the application, and it appears to still work. I can’t really explain it, but adding it (at least temporarily) resolved the issue so I thought I would spread the wealth.
At Monserrate Monastery in Bogotá, Colombia.