views:

68

answers:

1

say I have the following list that I provide to a django template

stuff= [ { 'a':2 , 'b':4 } , { 'a',7} ]

I want to access the 'a' attribute of the first element. I can't quite get the syntax right.

{{stuff|first}}

gives me the first element, but

{{stuff|first.a}}

is a dead end ( and weird )

and I can't seem to find a attribute filter. Short of writing one myself, is there template language syntax for what I want to do ?

stuff[0].a is no go as well
+4  A: 

This is off the top of my head, but I think it is

{{ stuff.0.a }}
Fred Larson