【问题标题】:Django customizing admin templates did not always change themDjango 自定义管理模板并不总是改变它们
【发布时间】:2019-03-20 07:43:22
【问题描述】:

从我的默认模板复制 base_site.html (project\Lib\site-packages\django\contrib\admin\templates\admin) 到我的应用程序 (project\mysite\polls\templates\admin),它适用于我的自定义版本。 但是使用 404.html 它不起作用 (我什至在原始模板中更改了它,仍然 404 完好无损)

【问题讨论】:

    标签: django templates admin customization default


    【解决方案1】:

    如文档中所述,不能基于每个应用覆盖 404 页面:

    对于那些无法以这种方式覆盖的模板,您仍然可以在整个项目中覆盖它们。只需将新版本放在您的模板/管理目录中。这对于创建自定义 404 和 500 页面特别有用。

    要覆盖管理面板的 404.html,请创建一个名为 404.html 的文件并将其放在 your_project/templates 文件夹中。

    在那之后转DEBUG=False。然后您将能够看到您的自定义 html。

    【讨论】:

      猜你喜欢
      • 2018-09-07
      • 2016-03-01
      • 2012-08-01
      • 2013-02-03
      • 2013-12-04
      • 1970-01-01
      • 1970-01-01
      • 2015-09-01
      相关资源
      最近更新 更多