On Mon, Mar 9, 2009 at 11:21 PM, Rama Vadakattu <ramaakrish...@gmail.com>wrote:
> > I have a list in template. > I need to access that list based on a forloop.counter. > > For example : > > if forloop.counter is 1 then i need to access list[1] > if forloop.counter is 5 then i need to access list[5] > . > so on.......... > > I tried below techniques to solve the above problem.but none of them > is working. > Any hint on how to do this? > > 1. {% for k in klist %} > > {{ mylist.forloop.counter }} #This code is not > working > {% endfor %} > > > 2. {% for k in klist %} > > {{% with forloop.counter as xl %} > {{mylist.x }} #This code is not working > {% endwith %} > > { %endfor %} > > 3. {% for k in klist %} > {{ mylist|slice:forloop.counter:forloop.counter }} #This > code is not working > { %endfor %} > > Regards > Rama vadakattu > > > > > > > > > > > > > is there a reason you can't just do {{ k }} why would an item be at a different position then it's index? Alex -- "I disapprove of what you say, but I will defend to the death your right to say it." --Voltaire "The people's good is the highest law."--Cicero --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---