How to break “for loop” in Django template

后端 未结 6 1831
甜味超标
甜味超标 2020-12-14 06:13

I have this code

    {% for account in object_list %}
        
        {% for field, value in book.get_fields %}
              {{ field.v         


        
6条回答
  •  独厮守ぢ
    2020-12-14 06:46

    You can't use break statement but you can choose not to print them on html. It's not a best solution but you can use it. I use the following one;

    {%for tumbnail in image %}
             {%if tumbnail.object_id == element.id %}
              
    
    {{ "" }}
    

    Its basicly seem like this on browser. http://i.stack.imgur.com/MPbR3.jpg

提交回复
热议问题