How do I check for last loop iteration in Django template?
Solution 1:
You would use forloop.last
. For example:
<ul>
{% for item in menu_items %}
<li{% if forloop.last %} class='last'{% endif %}>{{ item }}</li>
{% endfor %}
</ul>
Solution 2:
{{ forloop.last }}