1.创建一个名为templatetags的文件夹:
编写自定义filter
from django import template register=template.Library()
2.使用自定义filter
{# 先导入我们自定义filter那个文件 #}
{% load myfilter %} {{ name|happy }} {{ name|addstr:"hello world" }}
1.创建一个名为templatetags的文件夹:
编写自定义filter
from django import template register=template.Library()
2.使用自定义filter
{# 先导入我们自定义filter那个文件 #}
{% load myfilter %} {{ name|happy }} {{ name|addstr:"hello world" }}