我将数据存储在编码链接的数据库中,所以:
my_value = binascii.hexlify(value)
然后我想在Django模板中显示这些信息。
我如何在Django模板中解码'my_value'?
答案 0 :(得分:1)
如果无法将解码后的值提供到上下文中,则需要create a custom template tag.
from django import template
import binascii
register = template.Library()
@register.filter
def hex_decode(value):
return binascii.unhexlify(value)