2011-10-20 92 views
0

我有一个奇怪的问题。Django模板变量和列表索引

我使用分页程序中的每个页面中显示的一些数据,但是,我没有看到任何可能性增加我需要的型号等属性,所以我创建了带有额外的数据类型的字典的另一个列表。

模板:

{%为p.object_list%X}

{% with c=forloop.counter0 %} 

    {{ info.c }} <!-- prints nothing, while {{ info }} prints all the list of dicts and {{ c }} prints 0, for example. {{ info.0 }} prints everything as intended too. --> 

{% endwith %} 

{%ENDFOR%}

回答

1

{{ info.c }}访问info['c']info.c,等你而不是想要slice过滤器。