On 13 sep, 18:20, "David.D" <[email protected]> wrote: > In my template: > > This is ok: > {{ my_list.2 }} > > But it doesn't work: > {{ my_list.index }} > > index is a context variable (index=2)
This first looks up my_list for an attribute named "index" - which resolves to the "index" method of the list class if my_list is really a list - then try to do a dict lookup (ie: my_list["index"]). So technically speaking, it does "work" - in that does what the fine manual says it should do !-) Now, what's your use case exactly ? You don't need indexed access to iterate over a sequence, and if you know both my_list and index in your view (or templatetag or whatever), then you can just pass the appropriate value in your context from the view code itself. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

