'filter' is not a registered tag library


TemplateSyntaxError at /article-0-1.html

'filter' is not a registered tag library. Must be one of:
admin_list
admin_modify
admin_static
admin_urls
cache
i18n
l10n
log
static
staticfiles
tz

解决:新建的filter.py文件名是filter,封装这个函数的时候也是这个文件名。
from django import template


register = template.Library()
@register.simple_tag
def select_all(arg_dict):
因此:在HTML文件里{%load filter%},而不是def ***:这个函数名***


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM