Skip to content

Instantly share code, notes, and snippets.

@armonge
Created January 13, 2012 04:13
Show Gist options
  • Save armonge/1604653 to your computer and use it in GitHub Desktop.
Save armonge/1604653 to your computer and use it in GitHub Desktop.
Show an image in django admin list_display, using sorl-thumbnail
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
{% load thumbnail %}
{% thumbnail image '100x100' crop="top" as im %}
<img src="{{ im.url }}" alt="">
{% endthumbnail %}
@cherring07
Copy link

So simple!

@SalahAdDin
Copy link

thank you very much!

@GBarrera817
Copy link

where is your thumb.html??

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment