[Answered ]-Invalid Block Tag i=0, in Django

0👍

It depends on what you need it for. If you need the actual count, you can use a for loop in the template: http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for

Then you can use forloop.counter or forloop.counter0 to check the index.

If you just want to display a list of numbers you can use a html ordered list.

Django’s template engine is for design only, and you want to keep calculations out of it. If you need to do something with your data at the template layer you can write a custom tag/filter.

👤mk.

2👍

From http://www.djangobook.com/en/beta/chapter04/

{% for item in todo_list %}
    <p>{{ forloop.counter }}: {{ item }}</p>
{% endfor %}

Leave a comment