this question has answer here:
my problem is: have list of tuples variable accessed in django template file.
i want access third item of first tuple in list.
for example: if list is:
[(1,2,3,4),(5,6,7,8),(9,10,11,12)]
i want "3".
i've tried like:
{{lista | first . 3}}
and
{{(lista | first).3}}
but neither of these work.
inside template should able use dot notation , django unpack you:
{{ lista.0.2 }}
dots have special meaning in template rendering. dot in variable name signifies lookup. specifically, when template system encounters dot in variable name, tries following lookups, in order:
- dictionary lookup. example:
foo["bar"]
- attribute lookup. example:
foo.bar
- list-index lookup. example:
foo[bar]
Comments
Post a Comment