gpt4 book ai didi

django - 如何在 Django 中为 404 错误设置模板

转载 作者:行者123 更新时间:2023-12-01 01:27:48 25 4
gpt4 key购买 nike

我想做这里写的任何事情

Ensure that your 404 template works

Note that the FlatpageFallbackMiddleware only steps in once another view has successfully produced a 404 response. If another view or middleware class attempts to produce a 404 but ends up raising an exception instead (such as a TemplateDoesNotExist exception if your site does not have an appropriate template to use for HTTP 404 responses), the response will become an HTTP 500 (“Internal Server Error”) and the FlatpageFallbackMiddleware will not attempt to serve a flat page.



谁能告诉我制作 404 模板需要做什么

最佳答案

按照 setting up 404 handling 上的教程中的建议进行操作.

特别是,假设您不打算编写自己的 404 View ,这个建议很重要:

If DEBUG is set to False (in your settings module) and if you didn't create a 404.html file, an Http500 is raised instead. So remember to create a 404.html.

关于django - 如何在 Django 中为 404 错误设置模板,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6596230/

25 4 0
文章推荐: jakarta-ee - Glassfish 应用程序 URL
文章推荐: jquery - 组合两个函数来隐藏元素
文章推荐: 当选择更多选项时,jQuery 更改事件不会在 IE8 中的多个