-
-
Save somnathrakshit/24bd7becff3934b9e800915f3bf03f13 to your computer and use it in GitHub Desktop.
Show an image in django admin list_display, using sorl-thumbnail
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ProductAdmin(admin.ModelAdmin): | |
list_display = ('name','thumb') | |
def thumb(self, obj): | |
return render_to_string('thumb.html',{ | |
'image': obj.image | |
}) | |
thumb.allow_tags = True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load thumbnail %} | |
{% thumbnail image '100x100' crop="top" as im %} | |
<img src="{{ im.url }}" alt=""> | |
{% endthumbnail %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment