I'm using sorl-thumbnail to generate thumbnails for a list of images. Essentially my code looks like
{% for image in image_list %}
{% thumbnail image.image "158x158" crop="center" as im %}
{% endthumbnail %}
{% endfor %}
The problem is because I'm doing the thumbnail inside the for loop, every once in a while, sorl-thumbnail needs to run sql queries, which in my case, at one query per image, results in a huge db bottleneck. I need this process to be more efficient, say do all the thumbnail queries in the list at once?
So how can I make this thumbnail creation/retrieval process more efficient?