gpt4 book ai didi

python - Django/Python错误: ImproperlyConfigured; Middleware module does not define

转载 作者:太空宇宙 更新时间:2023-11-03 19:14:20 25 4
gpt4 key购买 nike

我是 Python/Django 新手。过去几天我尝试安装网络应用程序。安装看起来不错,但是当我访问该网站时,它给出了错误:“500 Internal Server Error”,并且error.log文件如下。

[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] mod_wsgi (pid=3554): Exception occurred processing WSGI script '/home/forum/forum.wsgi'.
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] Traceback (most recent call last):
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/wsgi.py", line 219, in __call__
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] self.load_middleware()
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/base.py", line 51, in load_middleware
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] mod_wsgi (pid=3554): Exception occurred processing WSGI script '/home/forum/forum.wsgi'.
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] Traceback (most recent call last):
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/wsgi.py", line 219, in __call__
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] self.load_middleware()
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/base.py", line 51, in load_middleware
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] raise exceptions.ImproperlyConfigured('Middleware module "%s" does not define a "%s" class' % (mw_module, mw_classname))
[Wed Aug 08 15:34:37 2012] [error] [client 192.168.0.10] ImproperlyConfigured: Middleware module "django.middleware.csrf" does not define a "CsrfResponseMiddleware" class

你有什么建议吗?谢谢

更新:

删除 Fedor Gogolev 提到的有关 CsrfViewMiddlewares 的行后。它给出了不同的错误日志:

[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] mod_wsgi (pid=3914): Exception occurred processing WSGI script '/home/forum/forum.wsgi'.
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] Traceback (most recent call last):
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/wsgi.py", line 219, in __call__
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] self.load_middleware()
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] mod = import_module(mw_module)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/utils/importlib.py", line 35, in import_module
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] __import__(name)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/middleware/extended_user.py", line 4, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] from forum.views.auth import forward_suspended_user
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/views/__init__.py", line 1, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] import readers
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/views/readers.py", line 20, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] from forum.utils import pagination
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/utils/pagination.py", line 173, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] page_numbers_template = template.loader.get_template('paginator/page_numbers.html')
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 145, in get_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] template, origin = find_template(template_name)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 134, in find_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] source, display_name = loader(name, dirs)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 42, in __call__
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] return self.load_template(template_name, template_dirs)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loaders/cached.py", line 46, in load_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] template, origin = self.find_template(template_name, template_dirs)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loaders/cached.py", line 31, in find_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] for loader in self.loaders:
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loaders/cached.py", line 26, in loaders
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] cached_loaders.append(find_template_loader(loader))
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 101, in find_template_loader
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] raise ImproperlyConfigured('Error importing template source loader %s: "%s"' % (loader, e))
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] ImproperlyConfigured: Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] mod_wsgi (pid=3914): Exception occurred processing WSGI script '/home/forum/forum.wsgi'.
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] Traceback (most recent call last):
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/wsgi.py", line 219, in __call__
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] self.load_middleware()
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/core/handlers/base.py", line 45, in load_middleware
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] mod = import_module(mw_module)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/utils/importlib.py", line 35, in import_module
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] __import__(name)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/middleware/extended_user.py", line 4, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] from forum.views.auth import forward_suspended_user
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/views/__init__.py", line 1, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] import readers
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/views/readers.py", line 20, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] from forum.utils import pagination
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/home/forum/forum/utils/pagination.py", line 173, in <module>
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] page_numbers_template = template.loader.get_template('paginator/page_numbers.html')
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 145, in get_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] template, origin = find_template(template_name)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 134, in find_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] source, display_name = loader(name, dirs)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 42, in __call__
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] return self.load_template(template_name, template_dirs)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loaders/cached.py", line 46, in load_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] template, origin = self.find_template(template_name, template_dirs)
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loaders/cached.py", line 31, in find_template
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] for loader in self.loaders:
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loaders/cached.py", line 26, in loaders
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] cached_loaders.append(find_template_loader(loader))
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] File "/usr/local/lib/python2.7/dist-packages/Django-1.4.1-py2.7.egg/django/template/loader.py", line 101, in find_template_loader
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] raise ImproperlyConfigured('Error importing template source loader %s: "%s"' % (loader, e))
[Wed Aug 08 16:18:44 2012] [error] [client 192.168.0.10] ImproperlyConfigured: Error importing template source loader django.template.loaders.filesystem.load_template_source: "'module' object has no attribute 'load_template_source'"

最佳答案

尝试在设置文件中的变量 MIDDLEWARE_CLASSES 中替换为 django.middleware.csrf.CsrfViewMiddleware,或者如果 CsrfViewMiddleware 已存在,则直接删除,因为 CsrfResponseMiddleware 已弃用。

关于python - Django/Python错误: ImproperlyConfigured; Middleware module does not define,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11872029/

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