Django 自定义管理模板并不总是改变它们
Django customizing admin templates did not always change them
从我的默认模板 (project\Lib\site-packages\django\contrib\admin\templates\admin) 复制 base_site.html
到我的应用程序 (project\mysite\polls\templates\admin),它适用于我的自定义版本。
但是对于 404.html 它不起作用
(我在原来的模板里改了,404还是完好无损)
404 页面不能像文档中提到的那样在每个应用程序的基础上被覆盖:
For those templates that cannot be overridden in this way, you may still override them for your entire project. Just place the new version in your templates/admin directory. This is particularly useful to create custom 404 and 500 pages.
要覆盖管理面板的 404.html,请创建一个名为 404.html 的文件并将其放在 your_project/templates 文件夹中。
在那之后 DEBUG=False
。然后你就可以看到你的自定义 html.
从我的默认模板 (project\Lib\site-packages\django\contrib\admin\templates\admin) 复制 base_site.html 到我的应用程序 (project\mysite\polls\templates\admin),它适用于我的自定义版本。 但是对于 404.html 它不起作用 (我在原来的模板里改了,404还是完好无损)
404 页面不能像文档中提到的那样在每个应用程序的基础上被覆盖:
For those templates that cannot be overridden in this way, you may still override them for your entire project. Just place the new version in your templates/admin directory. This is particularly useful to create custom 404 and 500 pages.
要覆盖管理面板的 404.html,请创建一个名为 404.html 的文件并将其放在 your_project/templates 文件夹中。
在那之后 DEBUG=False
。然后你就可以看到你的自定义 html.