我是Python / Django的新手。我在过去几天尝试过安装Web应用程序。安装似乎很好,但是当我访问网站时,它给出了一个错误:"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'"
答案 0 :(得分:1)
尝试在变量django.middleware.csrf.CsrfViewMiddleware
的设置文件中替换为MIDDLEWARE_CLASSES
,或者仅在CsrfViewMiddleware
已存在的情况下删除,因为CsrfResponseMiddleware
已被弃用。