lasted day63

过滤器的作用

1:用于改变变量的显示

内置过滤器

truncatewords

{{ value|truncatewords:9}}

timesince

自定义过滤器

1:在app下新建包文件命名templatetags
代码示例

from django import template
register = template.Library()
@register.filter(name="yourfiltername")
def operation(value):
    your logic
    return your value

使用
在html文件中

{% load '' %}