Django admin and showing thumbnail images

前端 未结 6 1685
春和景丽
春和景丽 2020-12-04 06:19

I\'m trying to show thumbnail images in Django admin, but I can only see the path to the images, but not the rendered images. I don\'t know what I\'m doing wrong.

Se

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 06:51

    Add a method in your model (models.py):

    def image_tag(self):
        return u'' % 
    image_tag.short_description = 'Image'
    image_tag.allow_tags = True
    

    and in your ModelAdmin (admin.py) add:

    readonly_fields = ('image_tag',)
    

提交回复
热议问题