1

I am new to Python/Django. I have tried over the past few days to install an web application. The installation seems fine, but when I accessed the website, it gave a error :"500 Internal Server Error" and the error.log file is as below.

[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

Do you have any suggestion? Thanks

updated:

After remove lines about CsrfViewMiddlewares as mention by Fedor Gogolev. It gave different error log:

[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'"
2
  • This is because the software you are trying to install is not compatible with the version of django (1.4) you are using. Commented Aug 8, 2012 at 19:53
  • it seems like that you are correct, it is not compatible. Any suggestion for this problem? Commented Aug 8, 2012 at 22:25

1 Answer 1

1

Try to replace to django.middleware.csrf.CsrfViewMiddleware in your settings file in variable MIDDLEWARE_CLASSES, or just remove if CsrfViewMiddleware already exists, because CsrfResponseMiddleware is deprecated.

Sign up to request clarification or add additional context in comments.

8 Comments

He means in settings.py. If you google your error you will find there is a deprecation issue with django 1.3 and 1.4 on this issue.
Probably you have settings.py or some similar file with django settings somewhere in your project directory.
@Fedor: django.middleware.csrf.CsrfViewMiddleware is already there. So I change to django.middleware.csrf ?
No, just remove a string with django.middleware.csrf.CsrfResponseMiddleware.
There is also a line django.middleware.csrf.CsrfResponseMiddleware. Do I need to change anything?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.