How do I add multiple arguments to my custom template filter in a django template?

前端 未结 9 520
时光说笑
时光说笑 2020-11-27 12:20

Here\'s my custom filter:

from django import template

register = template.Library()

@register.filter
def replace(value, cherche, remplacement):
    retur         


        
9条回答
  •  执念已碎
    2020-11-27 12:39

    Instead of a filter, register your tag as a simple tag. Those can take multiple arguments. The syntax for invoking it will be a little bit different, but that's just syntactic sugar changing.

提交回复
热议问题