def xnn_image(self, obj):
try:
img = mark_safe(
'<a href="{}" target="_blank"><img src="{}" width="25px" height="25px"/></a>'.format(
obj.legend_mf.url,
obj.legend_mf.url))
html1 = "<div>" + img + "</div><div></div>"
except Exception as e:
html1 = ''
return mark_safe(html1)
xnn_image.short_description = '电源线/GPS/GPRS安装'
xnn_image.allow_tags = True
xnn_image.admin_order_field = 'codeid'
标签:obj,img,缩略图,image,Django,html1,mark,xnn
From: https://www.cnblogs.com/jubai/p/16769813.html