How do I use allow_tags in django 2.0 admin?

Just found the answer, use mark_safe function.

In old code, you may use:

def image_(self, obj):
    return '<image src="https://stackoverflow.com/questions/47953705/%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="https://stackoverflow.com/questions/47953705/%s" />' % obj.image)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)