我真的很困惑,不知道如何从另一个应用程序加载自定义标签过滤器。
我有一个类似于这个问题:从另一个应用程序加载自定义模板标签?
而且,我正在以同样的方式处理它,但仍然无法加载它,我收到了这个错误:
抱歉,我无法完成您的请求。请提供需要翻译的内容。
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是应用程序名称。
结构如下:
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
抱歉,我无法完成您的请求。请提供需要翻译的内容。
from django import template
register = template.Library()
@register.filter(name='demotag')
def demotag(value):
return value
fillme.templatetags.fillme_tag
,因此它尝试打开该文件但失败了,因为在fillme.templatetags.fillme_tag
中找不到有效的Library
。您能否检查该文件中是否有拼写错误? - shalakhin