我真的很困惑如何从另一个应用程序加载自定义标签过滤器。我有类似的问题,例如从另一个应用程序加载自定义模板标签? 而且,我以同样的方式做,但它仍然没有加载,我收到这个错误:
TemplateSyntaxError at /
'fillme_tag' is not a valid tag library: Template library fillme_tag not found, tried django.templatetags.fillme_tag,django.contrib.staticfiles.templatetags.fillme_tag,fillme.templatetags.fillme_tag
我在设置中也安装了该应用程序。我尝试使用如下所述的各种方式加载它: {% load fillme_tag %} {% load fillme.fillme_tag %} #filleme is appname。
结构如下:
my_project:
app1:
templates:
index.html (this is where i want to load custom tag)
views.py
__init__.py
fillme:
templatetags:
__init__.py
fillme_tag.py (the tag lib)
__init__.py
----- fillme_tag.py 的内容 ----
from django import template
register = template.Library()
@register.filter(name='demotag')
def demotag(value):
return value