1.在app中创建templatetags目录,目录名必须为templatetags

2.在目录templatetags中创建一个.py文件,例如 strFilter.py

strFilter.py  #强制转换成str

from django import template

register = template.Library()

@register.filter("strVal")   
def strVal(value):
    return str(value)

 

index.html

{% load strFilter %}

{{ssidArr.id|strVal}}

 

相关文章:

  • 2021-06-17
  • 2022-12-23
  • 2021-08-08
  • 2022-12-23
  • 2021-08-29
  • 2021-08-10
  • 2021-10-27
  • 2022-12-23
猜你喜欢
  • 2021-08-30
  • 2021-09-06
  • 2021-12-05
  • 2022-12-23
  • 2022-12-23
  • 2021-07-09
相关资源
相似解决方案