Skip to main content

I want to display fallback content if the condition is not matched only one time. 

{% for feedItem in feeds.Firework.products %}
  {% if feedItem.productId == event.extra.line_items.0.product_id|floatadd:0 %}
    {{ feedItem.emailHtmlSmall | safe }}
  {% endif %}
{% endfor %}

 

@JaydeepPatel Please find below a solution that functions effectively if displaying fallback content at the end, regardless of whether a match is found, is acceptable. Unfortunately, Django's templating logic does not support the use of a break statement.

{% for feedItem in feeds.Firework.products %}
  {% if feedItem.productId == event.extra.line_items.0.product_id|floatadd:0 %}
    {{ feedItem.emailHtmlSmall | safe }}
  {% endif %}


{% if forloop.last %}

//fallback option

{% endif %}
{% endfor %}