New version of sorl-thumbnail , how show thumb in django admin?
-
03-12-2019 - |
Question
im using the new version of Sorl-thumbnail, but i cant show thumbs in django admin...
how ill use get_thumbnail() ?, just i can see the "cache" url of the images...
Thanks
Solution
i did it
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
OTHER TIPS
It's a new version with beter docs too! :) http://thumbnail.sorl.net/examples.html#admin-examples (This is for displaying images in forms, not in listing).
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow