Index method in Django's Template

Go To StackoverFlow.com

0

In my Django template I need to return the index of an item in a list.(index method in python) What is a way I could do this. Do I need to use a custom filter? Thank you.

2012-04-04 19:35
by Zach


2

If you want this inside a foor loop, you can use forloop.counter variable. Otherwise, you can use python to calculate it and pass it in the context to the template.

2012-04-04 19:39
by Hadi Moshayedi
Thanks a lot. Exactly what I was looking for - Zach 2012-04-04 19:44
Ads