从其他应用程序加载自定义模板标签? [英] Load custom template tag from another application?
本文介绍了从其他应用程序加载自定义模板标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的项目文件夹结构如下所示:
my_project:
app1:
templatetags:
my_tags1.py(包含简单的标签和包含标签)
app2:
templatetags:
my_tags2.py(包含一些简单的标签)
模板:
app1:index.html
app2:index.html
想法是使用标签来自my_tags1.py上的模板app2 / index.html。我只是试图:
{%load my_tags1%}
但这给我一个错误。
解决方案
确保标签文件有不同的名字。
Is this possible in any way? My project folder structure looks like this:
my_project:
app1:
templatetags:
my_tags1.py (contains simple tags and inclusion tags)
app2:
templatetags:
my_tags2.py (contains some simple tags)
templates:
app1: index.html
app2: index.html
The ideas is to use a tag from my_tags1.py on the template app2/index.html. I simply tried:
{% load my_tags1 %}
but that gives me an error.
解决方案
Make sure the tag files have different names.
这篇关于从其他应用程序加载自定义模板标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文