环境:
ws上的ubuntu django-1.4.5 in virtalenvdjango setting.py:
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\', '/'),)
apache2错误日志:
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] mod_wsgi (pid=1794): Exception occurred processing WSGI script '/home/ubuntu/Sites/tushanwan/tushanwan/wsgi.py'.
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] Traceback (most recent call last):
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 179, in get_response
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/utils/decorators.py", line 91, in _wrapped_view
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/views/defaults.py", line 32, in server_error
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/template/loader.py", line 145, in get_template
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] File "/home/ubuntu/.virtualenvs/django-1.4.5/lib/python2.7/site-packages/django/template/loader.py", line 138, in find_template
[Mon Mar 11 22:18:55 2013] [error] [client 116.238.171.102] TemplateDoesNotExist: 500.html
我花了一天时间,尝试了很多方法在我的usntu实例上解决这个问题,但它们也没有为我工作。我使用相同的方法在我的本地ubuntu服务器上部署django应用程序,它可以工作。
答案 0 :(得分:3)
来自:https://docs.djangoproject.com/en/dev/topics/http/views/#the-500-server-error-view
如果DEBUG设置为True(在您的设置模块中),那么您的500视图 将永远不会被使用,而且将显示回溯 一些调试信息。
所以在你的开发服务器中,一切都可以正常工作,如果你的生产服务器中你没有500.html(在你的模板文件夹的根目录下),那么框架会出错。
附注:Django 1.4.x中需要404.html和500.html文件;在Django 1.5.x中,不再严格要求500.html和404.html文件,谢谢to this patch