On 18 January 2011 15:02, Thomas <tho...@googlemail.com> wrote: > > Am 18.01.2011 um 14:53 schrieb GD: > >> >> 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? >>
You can write a filter: http://docs.djangoproject.com/en/1.2/howto/custom-template-tags/#writing-custom-template-filters >> {% for x in a %} >> loop number = {{forloop.counter|increase}} >> {% endfor %} cheers, Konrad -- 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.