python – 在django中注册自定义过滤器
发布时间:2020-12-20 11:36:57 所属栏目:Python 来源:网络整理
导读:我的过滤器没有注册,也不确定它被绊倒的地方. 在test / templatetags中 __init__.pytest_tags.py test_tags.py包括 from django import templateregister.filter('intcomma',intcomma)def intcomma(value): return value + 1 test / templates包含pdf_test.h
我的过滤器没有注册,也不确定它被绊倒的地方.
在test / templatetags中 __init__.py test_tags.py test_tags.py包括 from django import template register.filter('intcomma',intcomma) def intcomma(value): return value + 1 test / templates包含pdf_test.html,其中包含以下内容 {% load test_tags %} <ul> <li>{{ value |intcomma |floatformat:"0"</li> </ul> 浮动格式工作正常,但intcomma没有运气 解决方法
首先,你
haven’t defined
register :
另外,我通常用 from django import template register = template.Library() @register.filter def intcomma(value): return value + 1 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |