[英]Loading django custom template tag at onece
I have my custom template tag. 我有我的自定义模板标签。 How to load it at once, without
{% load tag %}
in every template-file? 如何一次加载它,而在每个模板文件中都没有
{% load tag %}
?
UPD: UPD:
As suggested by Yuji: 如Yuji所建议:
from django.template.loader import add_to_builtins
add_to_builtins('myapp.templatetags.mytagslib')
however, I don't use django, only templates - what should i write instead of myapp.templatetags.mytagslib
? 但是,我不只使用django,而仅使用模板-代替
myapp.templatetags.mytagslib
应该写什么?
UPD2: ok, tried django.templatetags...
, works ;-) UPD2:好的,尝试过
django.templatetags...
,有效;-)
Here you go: 干得好:
Load a Django template tag library for all views by default 默认情况下为所有视图加载Django模板标签库
Favorite Django Tips & Features? 最喜欢的Django提示和功能?
I will remember this one, thanks :) 我会记住这一点,谢谢:)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.