~表明你的态度~





当前已表态的用户(1人):
一稚杨
# -*- coding: utf-8 -*- # @File : custom_label.py # @Author: 一稚杨 # @Date : 2018/12/30/030 # @Desc : 自定义标签过滤器 from django import template register = template.Library() # 使用simple_tag注册标签过滤器 @register.simple_tag # 定义标签过滤器方法,参数没有限制且没有默认参数 def test_label(date, author, content): return str(date) + author + content前端使用方法也是先使用
{% load custom_label %}
引入,再使用{% test_label blog.date blog.author blog.content|test:'123' %}
来使用,参数与参数之间使用空格区分,同时也可以嵌入变量过滤器。