views:

1284

answers:

2

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

+11  A: 

You would use forloop.last. For example:

<ul>
{% for item in menu_items %}
    <li{% if forloop.last %} class='last'{% endif %}>{{ item }}</li>
{% endfor %}
</ul>
Paolo Bergantino
That was what I needed!
Daniel
+2  A: 

{{ forloop.last }}

fuentesjr
Thanks that is what I was looking for!
Daniel