how to print a data structure in django template

1 view
Skip to first unread message

mahesh_aka_amol

unread,
Nov 14, 2008, 11:50:21 AM11/14/08
to Django users
I have a a family tree; as describd below

>>> son={'first':'Swami', 'last':'Vaidya'}
>>> family={'f':father, 's':son}
>>> family
{'s': {'last': 'Vaidya', 'first': 'Swami'}, 'f': {'last': 'Vaidya',
'first': 'Mahesh'}}

I would like to render this in template.; What I can think of is

{% for key in family.keys %}

<li> { key } </li>

# this will give me father / son

{ % endfor %}

My problem how do I access parts like family['f'']['first'] should
give me "Mahesh" and family['s']['last'] should gibe me 'Swami;

Thank You
-Mahesh

Steve Holden

unread,
Nov 14, 2008, 1:43:15 PM11/14/08
to django...@googlegroups.com
{{ family.f.first }}
{{ family.s.last }}

regards
Steve
--
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/

Reply all
Reply to author
Forward
0 new messages