Skip to main content
 首页 » 编程设计

python之django 管理员更改 View 不显示图像缩略图

2024年10月24日20lovecherry

我可以在管理 ListView 中列出图像缩略图。我在我的模型中做到了这一点

def category_image(self): 
    return '<img height=100px; width=100px; src="{}" />'.format(self.category_media.url) 
 
category_image.short_description = 'Image' 
category_image.allow_tags = True 

但是当我去更改 View 时,我看不到图像。我刚得到网址。 我也想要一个缩略图。我该怎么做?

请您参考如下方法:

尝试替换'<img ...'与 <img style="height=100px; width=100px;" src="{}" /> .