gpt4 book ai didi

python - 配置不当 : Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class

转载 作者:太空狗 更新时间:2023-10-30 00:46:26 28 4
gpt4 key购买 nike

我在本地开发环境中没有这个问题,但我只是使用 nginx + gunicorn 部署了应用程序(第一次部署应用程序),每当我尝试发出请求时都会收到此回溯。

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

以下是我的settings.py文件的一部分

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

谁能给我指出正确的方向?

最佳答案

看起来您部署的服务器有不同版本的 Django(旧版本)。 Penthi 也是对的,CsrfResponseMiddleware 是为了向后兼容,应该被删除。 https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/#legacy-method .

关于python - 配置不当 : Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8953783/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com