简体   繁体   English

在Django中,如何从另一个模板中引用一个模板?

[英]In Django, how do I reference one template from another one?

I'm using Django and Python 3.7. 我正在使用Django和Python 3.7。 I have these two files ... 我有这两个文件......

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

In my base.html file, I try and include the navigation template like so 在我的base.html文件中,我尝试包含这样的导航模板

    {% include "navigation.html" %}

However, when I restart my Django app, I get this error 但是,当我重新启动我的Django应用程序时,我收到此错误

TemplateDoesNotExist at /navigation.html

How do I reference my navigation template from my base template? 如何从我的基本模板中引用我的导航模板?

Have you tried adding the folder name which it is located under: eg 您是否尝试添加它所在的文件夹名称:例如

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从一个 django 模型访问图像 URL 到另一个模型? 如何将它放在模板上? - How do I access image URL from one django model to another? How do I put it on a template? 如何在另一个应用程序中使用一个应用程序中的模板 - How do I use a template from one app in another app 如何在Django中以多对一关系将一个模型对象添加到另一模型的ModelForm模板中? - How do I add one model objects to another model’s ModelForm template with many to one relationship in Django? 如何在Django中将列表从一个视图传递到另一个视图? - How do I pass a list from one view to another in Django? Django,如何将数据对象从一个模板传递到另一个模板 - Django, How to pass data object from one template to another template 如何在Django 2中将模板标签从一个模板传递到另一个模板 - How to pass a template tag from one template to another in django 2 如何在Django中将参数从一个模板发送到另一个模板/视图? - How can i send parameters from one template to another template/view in django? 在 Python/Django 中,如何从我创建的另一项服务导入我创建的一项服务? - In Python/Django, how do I import one service I created from another one I created? 如何在另一个模板语言中使用 Django 模板语言? - How can I use Django template language inside another one? 如何在另一个 python django 模板中显示 javascriptfunctions 结果? - How can I display javascriptfunctions results from one python django template in another?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM