django - 新版本的 sorl-thumbnail ,如何在 django admin 中显示拇指?

标签 django django-admin sorl-thumbnail

我正在使用新版本的 Sorl-thumbnail,但我无法在 django admin 中显示拇指...

如何使用 get_thumbnail() ?,只是我可以看到图像的“缓存”url...

谢谢

最佳答案

我做到了

from sorl.thumbnail import get_thumbnail
def thumb(self):
        if self.imagen:
            t = get_thumbnail(self.imagen,"50x50",crop='center', quality=99)
            return u'<img src="%s" />' % t.url            
        else:
            return u"None"
    thumb.short_description = 'Foto'
    thumb.allow_tags = True 

关于django - 新版本的 sorl-thumbnail ,如何在 django admin 中显示拇指?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5073570/

相关文章:

python - Django 自定义管理站点在模型 View 中不起作用

python - 如何将 sorl-thumbnail 集成到现有的 django 项目中?

javascript - 需要帮助处理 Django 中的日期格式

python - 使用 Django South 处理大型项目的迁移是否安全

python - Django truncatewords 并显示搜索到的词

django - 根据其他字段限制外部字段的选择

python - 使用 Django 和 python 迁移模型时出现错误

python - 使用 Django 1.7 进行 sorl-thumbnail 的最小开发人员设置

python - Sorl-缩略图错误 502 大图像

python - 如何升级 django 项目的多个版本(1.8 到 1.11+)?