Answers for "how to put image in html from django from the admin"

0

django admin image

from django.utils.html import format_html

@admin.register(Model1) 
class Model1Admin(admin.ModelAdmin):

    def image_tag(self, obj):
        return format_html('<img src="{}" />'.format(obj.image.url))

    image_tag.short_description = 'Image'

    list_display = ['image_tag',]
Posted by: Guest on January-11-2021

Code answers related to "how to put image in html from django from the admin"

Python Answers by Framework

Browse Popular Code Answers by Language