How do I check for last loop iteration in Django template?

前端 未结 2 1854
忘了有多久
忘了有多久 2020-12-24 11:25

I have a basic question, in the Django template language how can you tell if you are at the last loop iteration in a for loop?

2条回答
  •  無奈伤痛
    2020-12-24 11:56

    You would use forloop.last. For example:

      {% for item in menu_items %} {{ item }} {% endfor %}

提交回复
热议问题