[Answered ]-Django templates avoid loop

1๐Ÿ‘

โœ…

You can achieve by using either with tag to set a variable or direclty us as:

{% with skus=i.skus.first %}
    <h6 class="card-price">{{skus.price}} {{skus.currency}}</h6
{% endwith %}

or

<h6 class="card-price">{{i.skus.first.price}} {{i.skus.first.currency}}</h6
๐Ÿ‘คshah sawood

0๐Ÿ‘

You may be looking for the first queryset method:

<div class="card-body">
  <img src={{i.images.first().img_url}} class="card-img-top" alt="...">
</div>
๐Ÿ‘คNicolas Appriou

Leave a comment