开发者

referencing a key/value in django-templates after applying a filter

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' at开发者_如何转开发tribute 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


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

{{ stuff.0.a }}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜