如何在Django 2.0管理员中使用allow_tags? [英] How do I use allow_tags in django 2.0 admin?
本文介绍了如何在Django 2.0管理员中使用allow_tags?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
已删除对ModelAdmin方法的allow_tags属性的支持。
Support for the allow_tags attribute on ModelAdmin methods is removed.
推荐答案
刚刚找到答案,请使用 mark_safe
函数。
Just found the answer, use mark_safe
function.
在旧代码中,您可以使用:
In old code, you may use:
def image_(self, obj):
return '<image src="%s" />' % obj.image
image_.allow_tags = True
在新代码中,您应该使用:
In new code, you should use:
from django.utils.safestring import mark_safe
def image(self, obj):
return mark_safe('<image src="%s" />' % obj.image)
这篇关于如何在Django 2.0管理员中使用allow_tags?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文