【问题标题】:In Django, how do I reference one template from another one?在 Django 中,如何从另一个模板引用一个模板?
【发布时间】:2019-04-04 20:43:24
【问题描述】:

我正在使用 Django 和 Python 3.7。我有这两个文件...

appname/templates/appname/base.html
appname/templates/appname/navigation.html

在我的 base.html 文件中,我尝试像这样包含导航模板

    {% include "navigation.html" %}

但是,当我重新启动我的 Django 应用程序时,我收到了这个错误

TemplateDoesNotExist at /navigation.html

如何从我的基本模板中引用我的导航模板?

【问题讨论】:

标签: django python-3.x templates navigation


【解决方案1】:

您是否尝试过添加它所在的文件夹名称:例如

{% include 'appname/navigation.html' %}

【讨论】:

    猜你喜欢
    • 2013-06-13
    • 2018-02-02
    • 2021-06-30
    • 1970-01-01
    • 2012-07-05
    • 1970-01-01
    • 1970-01-01
    • 2012-06-14
    相关资源
    最近更新 更多