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

后端 未结 3 1231
庸人自扰
庸人自扰 2021-01-13 13:42

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 traceba

3条回答
  •  失恋的感觉
    2021-01-13 13:51

    In Django 1.4, you should remove the 'django.middleware.csrf.CsrfResponseMiddleware', because it can cause security problems.

    Furthermore, two things must be done.

    1. Add a {% csrf_token %} tag to your post form.
    2. Use RequestContext instead of Context in all of your relative views.py files.

提交回复
热议问题