【发布时间】:2013-10-28 06:34:06
【问题描述】:
我正在部署 django 页面,终于可以运行了,但在生产服务器中找不到 500 模板,我在var/log/apache2/error.log 中收到此错误:
raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html
我创建了 500.html 和 404.html 模板,它们位于 templates 目录下。这是我的 settings.py
import os
gettext = lambda s: s
PROJECT_PATH = os.path.abspath(os.path.dirname(__file__))
TEMPLATE_DIRS = (
"templates",
os.path.join(PROJECT_PATH, "templates"),
)
我错过了什么?为什么服务器找不到500.html,即使它在那里?
【问题讨论】:
-
请在您的网站上尝试随机路径,例如“/sdfjlksjfdsd”,请告诉我发生了什么?您是否将 DEBUG=False 放入您的 settings.py 文件中?
-
@SrinivasReddyThatiparthy,是的,我输入了
DEBUG=False。如果我将其更改为True,我会得到正常的错误回溯,但这不应该在产品服务器中。 -
@SrinivasReddyThatiparthy,你说的另一条路是什么意思?而不是
templates另一条路径? -
我只是在模拟 404.html 功能。如果你给一些随机路径,它应该显示 404.html 对吗?试试看。让我知道 404.html 工作正常吗?
-
@SrinivasReddyThatiparthy,是的,404 正在工作。