How do I render a template variable inside a for loop, when the var is a dict and the key is forloop.counter
Hi,
I have a dict var defined in server side, like PHONE_BOOK={1:'634534',
2:'264886', 3:'455346' etc..}
Then in my django template I have this loop where I need to print the
PHONE_BOOK[loop counter]:
{% for Item in MyList %}
Item.first_name | PHONE_BOOK.forloop.counter
{% endfor %}
---------------------------------
For some reason PHONE_BOOK.forloop.counter doesn't work and neither
the more direct ways like PHONE_BOOK[forloop.counter]; it seems to me
that there's a bit of an inflexibility in the django template renderin
mechanism.
Any idea how to solve that?
Thanks.
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home