[Answered ]-Django Templates Syntax Error For If (Could not parse the remainder)

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 %}
👤Snerd

Leave a comment