如何为我的 Django/Apache 创建自定义 404 页面?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1569682/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 18:17:00  来源:igfitidea点击:

How to create a custom 404 page for my Django/Apache?

pythondjangoapache

提问by TIMEX

I know that you use .htaccessin the document-root directory in standard Apache. What if I use Django? Can someone give me step by step how to create a custom 404 page?

我知道您.htaccess在标准 Apache 的文档根目录中使用。如果我使用 Django 怎么办?有人可以给我一步一步如何创建自定义 404 页面吗?

回答by Ben Regenspan

The default 404 handler calls 404.html . You could edit that if you don't need anything fancy or can override the 404 handler by setting the handler404 view -- more here

默认的 404 处理程序调用 404.html 。如果您不需要任何花哨的东西,或者可以通过设置 handler404 视图来覆盖 404 处理程序,您可以编辑它——更多在这里