1

我是 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

你有什么建议吗?谢谢

更新:

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

[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'"
4

1 回答 1

1

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

于 2012-08-08T19:50:18.540 回答