【问题标题】:Mezzanine 404 and 500 errors template not overriding夹层 404 和 500 错误模板未覆盖
【发布时间】:2016-10-15 22:21:32
【问题描述】:

我正在使用 Mezzanine 并希望覆盖通用 Django 404 和 500 页面模板。我将错误文件夹复制到:

my_theme/templates/errors

错误中的 404.html 和 500.html 模板应覆盖通用模板,但它们不会...我尝试将这两个文件也直接复制到 /templates 文件夹中,但无法正常工作。

【问题讨论】:

  • 我对主题一无所知,但我怀疑您的模板目录不在搜索路径中。我会看看你的模板设置。
  • 谢谢,但我认为情况并非如此,因为我在同一模板目录中有其他文件,并且它们正确地覆盖了模板...

标签: django error-handling mezzanine custom-error-pages errortemplate


【解决方案1】:

您使用的是哪个版本的夹层?在旧版本中,模板路径应该是 my_theme/templates/ 而不是 my_theme/templates/errors/ 。 见:https://groups.google.com/forum/#!topic/mezzanine-users/5N94Q33uwvc

此外,您是否在设置中定义了 DIRS?像这样:

TEMPLATES = [
    {
        "DIRS": [
            os.path.join(PROJECT_ROOT, "templates")
        ],
    ...

见:https://docs.djangoproject.com/en/1.11/topics/templates/#configuration

【讨论】:

    猜你喜欢
    • 2012-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-01-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多