Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class

I don't have this problem on my local development environment, but I just deployed the app with nginx + gunicorn (first time deploying an app) and I am getting this traceback whenever I try to make a request.

2012-01-21 22:24:36 [5712] [ERROR] Error handling request
Traceback (most recent call last):
  File "/usr/lib/pymodules/python2.7/gunicorn/workers/sync.py", line 96, in handle_request
    respiter = self.wsgi(environ, resp.start_response)
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 219, in __call__
    self.load_middleware()
  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 51, in load_middleware
    raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))
ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class

The following is a part of my settings.py file

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',
)

Anyone can point me in the right direction?

like image 415
bash- Avatar asked Jan 21 '12 14:01

bash-


1 Answers

Looks like the server where you deployed has different version of Django (old one). Also Penthi is right, CsrfResponseMiddleware is for backward compatibility and should be removed. https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#legacy-method.

like image 180
demalexx Avatar answered Jan 03 '23 15:01

demalexx