Skip to main content
Solved

Break a loop when a condition is met?

  • June 11, 2025
  • 1 reply
  • 50 views

Forum|alt.badge.img+5

I want to break the loop once a specific condition is matched inside a nested loop. Here’s a simplified version of my code:

{% for s in event.ESPPayload.vars.Shipment %}
  {% if s.Items|length > 0 %}
    {% for c in s.Items %}
      {% if c.availabilityStatus|lower != "preorder" %}
        <table role="presentation" border="0" align="center" cellpadding="0" cellspacing="0" width="100%" style="background:#FFFFFF;font-size: 14px; font-weight: bold;">
          <tbody>
            <tr>
              <td align="{{ align|default:'left' }}" style="padding: {{ padding_top|default:'20' }}px 50px {{ padding_bottom|default:'20' }}px 50px;">
                YOUR ORDER
              </td>
            </tr>
          </tbody>
        </table>

      {% endif %}
       
    {% endfor %}

  {% endif %}
{% endfor %}
 

Best answer by TJ Mapes

Hey there, sorry to tell you but after some research I’m not sure Django supports break or continue tags.

1 reply

TJ Mapes
Problem Solver IV
Forum|alt.badge.img+9
  • 2025 Champion
  • 28 replies
  • Answer
  • June 11, 2025

Hey there, sorry to tell you but after some research I’m not sure Django supports break or continue tags.