django forloop.en contre-opération Je voudrais savoir comment reproduire cela dans django: for photo in gallery if counter is 1 then use this photo endif endfor comment puis-je vérifier le forloop contre si c'est "1"? OriginalL'auteur Fel | 2011-03-11 djangodjango-templatesfor-loop 33 {% for photo in gallery %} {% if forloop.counter == 1 %} Do something with {{ photo }}. {% endif %} {% endfor %} ceci est équivalent à: {% for photo in gallery %} {% if forloop.first %} Do something with {{ photo }}. {% endif %} {% endfor %} Référence: Django docs OriginalL'auteur Shawn Chin Vous devez vous connecter pour publier un commentaire.
ceci est équivalent à:
Référence: Django docs
OriginalL'auteur Shawn Chin