I am trying to have the pictures I upload in the Django admin panel to show up as thumbnails instead of the path. I have sorl installed and can make thumbnails that show up in my views.
I have found 2 snippets (http://www.djangosnippets.org/snippets/579/ and http://www.djangosnippets.org/snippets/934/) that I have tried to implement, but both attempts have failed because of the meager documentation and my as yet shallow understanding of the Django framework.
Could someone please provide a dumbed-down step-by-step guide of how I can get this to work?
Thanks!
Yeah ๐ I can ๐
First you need to create a custom template tag that handles the thumbnail:
where item.preview.thumbnail_tag is the thumnail created by sorl ๐
[I got the original code from the default template tag]
Second you need to create a template for your model (that uses the new custom template tag), it must be in this directory schema:
templates_dir/admin/app_name/model/change_list.html
and have the following code:
as you can see in the tag function you need to create one more template (called change_list_result.html) for display the image correctly:
so at the end you’ll have 3 files:
and, of course, templatetags must be added to INSTALLED_APP in settings ๐
this is all ๐ Hope this can be helpful.