不需要将标记注册到模板。你只需要从那里把它装进去。你已经在做了。
因此,只需替换:
@register.simple_tag('loansTable.html')
有了这个:
@register.simple_tag
您还需要将自定义标记放在 templatetags
templatetags
在你的 index.html索引 i、 e.如果你在里面登记了标签 custom_tags.py 文件
custom_tags.py
{% load custom_tags %}
初始 .py文件以确保将目录视为Python包。