Django как получить доступ к результату из queryset в шаблоне из индекса

У меня есть queryset результат в шаблоне:

{% for image in product.productimages_set.all %}
<img src="{{ image.image_file.url }}"/>
{% endfor %}

Как я могу получить доступ к индексу этого объекта в шаблоне, т.е.:

<img src="{{ product.productimages_set.all.0 }}"/>

Можно получить доступ к индексу, используя forloop.counter

{% for image in product.productimages_set.all %}
{% if forloop.counter == 0 %}
<img src="{{ image.image_file.url }}"/>
{% else %}
{% if forloop.counter == 1 %}
<img src="{{ image.image_file.url }}"/>
{% endif %}
{% endfor %}
Вернуться на верх