Comment casser “boucle” dans Django template

J'ai ce code

    {% for account in object_list %}
        <tr>
        {% for field, value in book.get_fields %}
              <th>{{ field.verbose_name }}</th> 
        {% endfor %}
        </tr>
    {{ break }}
    {% endfor %}

J'ai envie de casser la boucle après la première itération. pause n'est pas de travail

  • Pourquoi utiliser une boucle si vous souhaitez arrêter après la première itération? Utilisation {% with account=object_list|first %} ... {% endwith %}
  • merci , je ne savait pas que
  • Voir aussi stackoverflow.com/questions/10397470/...
InformationsquelleAutor tej.tan | 2011-06-28