http://docs.djangoproject.com/en/dev/ref/templates/builtins/?from=olddocs#add

There is loop.counter and loop.counter0. loop.counter starts from 1,
and loop.counter0 starts from 0.  The 3rd time through a for loop
loop.counter is 3 and loop.counter0 is 2.

If you want to add things try something like this:

{{ value|add:"2" }}

if value was 3 then 5 would be output.



On Jan 18, 1:53 pm, GD <gerarddev...@googlemail.com> wrote:
> Hi everyone,
>      Is there a way to do simple loop counter manipulation within the
> template? I.e something along the lines of:
>
> {% for x in a %}
>       loop number = {{forloop.counter +1}}
> {% endfor %}
>
> with the intention of
>
> 2
> 3
> 4
> ....
>
> as output. I realise the above doesn't work, but is there any scope
> for this sort of thing within the templating language itself?
>
> Regards,
> G

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to