Django:404.html存在但使用了500.html

时间:2013-07-29 10:32:02

标签: django django-templates

http://127.0.0.1:8000/app/slug/

Debug=True我得到Page not found (404) - No entry found matching the query。使用Debug=False,我会看到projectName/templates/500.html而不是404.html

两者看起来完全一样。 500.html

{% extends "base.html" %}

{% block title %}server error{% endblock %}

{% block content %}

<h3>Error 500: server error</h3>

{% endblock %}

404.html

{% extends "base.html" %}

{% block title %}page not found{% endblock %}

{% block content %}

<h3>Error 404: page not found</h3>

{% endblock %}

为什么Django加载500而不是404,尽管它存在?它不能是模板错误。

1 个答案:

答案 0 :(得分:0)

如果你100%确定你在设置中正确设置了ALLOWED_HOSTS,那么你的404.html模板可能不正确。可能存在语法错误(或者找不到基本模板),这反过来会导致引发新的500异常。

尝试通过仅包含静态HTML来简化您的404.html。