Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
将django应用程序部署到生产服务器时出现Get TemplateDoesNotExist错误_Django_Apache_Deployment - Fatal编程技术网

将django应用程序部署到生产服务器时出现Get TemplateDoesNotExist错误

将django应用程序部署到生产服务器时出现Get TemplateDoesNotExist错误,django,apache,deployment,Django,Apache,Deployment,环境: aws上的ubuntu 病毒环境中的django-1.4.5 使用wsgi的apache-2.2 django 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_wsg

环境:

aws上的ubuntu
病毒环境中的django-1.4.5
使用wsgi的apache-2.2

django 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
我花了一天的时间,在我的aws ubuntu实例上尝试了许多方法来解决这个问题,但这些方法对我都不起作用。我用同样的方法在本地ubuntu服务器上部署django应用程序,它可以正常工作。

来自:

如果DEBUG设置为True(在设置模块中),则您的500视图 将永远不会使用,而将显示回溯,并显示 一些调试信息

因此,尽管在开发服务器中一切都可以正常工作,但如果在生产服务器中没有500.html(在模板文件夹的根目录中),那么框架将出现错误

旁注:Django 1.4.x中需要404.html和500.html文件;在Django 1.5.x中,不再严格要求500.html和404.html文件,谢谢:

如果DEBUG设置为True(在设置模块中),则您的500视图 将永远不会使用,而将显示回溯,并显示 一些调试信息

因此,尽管在开发服务器中一切都可以正常工作,但如果在生产服务器中没有500.html(在模板文件夹的根目录中),那么框架将出现错误


旁注:Django 1.4.x中需要404.html和500.html文件;在Django 1.5.x中,500.html和404.html文件不再是严格要求的,谢谢

您是否将DEBUG设置为TRUE?是否将DEBUG设置为TRUE?我在模板中添加了500.html。但在我添加的500.html呈现的apache错误日志文件中仍然会出现TemplateDoesNotExist错误。是否重新启动了apache?500.html文件权限是否正常?是的,apache已重新启动,500.html的权限为644。模板目录是否被覆盖?打开django shell并键入“from django.conf import settings;print settings.TEMPLATE_DIRS”会产生什么结果?作为一种解决方法,您可以升级到django 1.5。它不应该出现这种错误。您还可以临时将DEBUG和TEMPLATE_DEBUG设置为True,以查看是否得到一些提示。最后,我们没有任何关于异常原因的信息。。。也许这是一个例外的结果,一些设置变得不可用?我在我的模板中添加了一个500.html。但在我添加的500.html呈现的apache错误日志文件中仍然会出现TemplateDoesNotExist错误。是否重新启动了apache?500.html文件权限是否正常?是的,apache已重新启动,500.html的权限为644。模板目录是否被覆盖?打开django shell并键入“from django.conf import settings;print settings.TEMPLATE_DIRS”会产生什么结果?作为一种解决方法,您可以升级到django 1.5。它不应该出现这种错误。您还可以临时将DEBUG和TEMPLATE_DEBUG设置为True,以查看是否得到一些提示。最后,我们没有任何关于异常原因的信息。。。也许作为例外的结果,某些设置变得不可用?