1👍
You can work with the |last
template filter [Django-doc] to obtain the last item of a sequence:
{% for img in image_list %} {% if img != image_list|last %} <img src="{{ img.image.url }}" class="img-fluid rounded" alt="Recipe Image Secondary"> <br> {% endif %} {% endfor %}
or in this case work with forloop.last
[Django-doc]:
{% for img in image_list %} {% if not forloop.last %} <img src="{{ img.image.url }}" class="img-fluid rounded" alt="Recipe Image Secondary"> <br> {% endif %} {% endfor %}
0👍
{% for img in image_list %}
{% if not forloop.last %}
<img src="{% get_media_prefix %}{{ img.image }}" class="img-fluid rounded" alt="Recipe Image Secondary">
<br><br>
{% else %}
<img src="{% get_media_prefix %}{{ img.image }}" class="img-fluid rounded" alt="Recipe Image Secondary">
{% endif %}
{% endfor %}
- [Answered ]-Django users groups
- [Answered ]-Populate parent field from url kwarg in a nested serializer in Django REST Framework
Source:stackexchange.com