Der*_*rek 6 python django django-templates sorl-thumbnail
我正在使用 sorl-thumbnail 为图像列表生成缩略图。基本上我的代码看起来像
{% for image in image_list %}
{% thumbnail image.image "158x158" crop="center" as im %}
{% endthumbnail %}
{% endfor %}
Run Code Online (Sandbox Code Playgroud)
问题是因为我在 for 循环中执行缩略图,每隔一段时间,sorl-thumbnail 需要运行 sql 查询,在我的情况下,每个图像一个查询,导致巨大的数据库瓶颈。我需要这个过程更有效,比如说一次执行列表中的所有缩略图查询?
那么我怎样才能使这个缩略图创建/检索过程更有效呢?