Re: accessing dict values in a template

2009-09-29 Thread gontran
that's right! thank you! I don't know how I missed that information in the doc... On 29 sep, 23:51, Javier Guerra wrote: > sorry, the right syntax is > >  {% for key, element in toto.items %} >     Name: {{ element.name }} - Desc: {{ element.desc }} >  {% endfor %} > > (as documented > inhttp:/

Re: accessing dict values in a template

2009-09-29 Thread Javier Guerra
sorry, the right syntax is {% for key, element in toto.items %}    Name: {{ element.name }} - Desc: {{ element.desc }} {% endfor %} (as documented in http://docs.djangoproject.com/en/dev/ref/templates/builtins/#for ) -- Javier --~--~-~--~~~---~--~~ You recei

Re: accessing dict values in a template

2009-09-29 Thread gontran
It doesn't change anything On 29 sep, 21:39, Javier Guerra wrote: > On Tue, Sep 29, 2009 at 2:35 PM, gontran wrote: > > In my template, I want to access to the name and to the desc of each > > key of toto: > > {% for element in toto %} > >    Name: {{ element.name }} - Desc: {{ element.desc }}

Re: accessing dict values in a template

2009-09-29 Thread Javier Guerra
On Tue, Sep 29, 2009 at 2:35 PM, gontran wrote: > In my template, I want to access to the name and to the desc of each > key of toto: > {% for element in toto %} >    Name: {{ element.name }} - Desc: {{ element.desc }} > {% endfor %} try: {% for key, element in toto %} Name: {{ element.name

accessing dict values in a template

2009-09-29 Thread gontran
Hello, here is my problem: I have a dictionary which keys are unknown and which values are dictionaries. (I don't know the keys because they are dynamically created by a loop) For example: toto = {} toto['123'] = {} toto['123']['name'] = 'name of 123' toto['123']['desc'] = 'desc of 123' toto['45