python - accessing a list of tuples in html -


i have list of tuples called top_5 top 5 users usernames , corresponding post count.

this list has 5 items , each item has 2 indexes.

{% user in top_5 %}    {{ user }} {% endfor %} 

returns user , post count there way can them separately?

is django template? can access index values in django template using dot notation:

{% user in top_5 %}     {{ user.0 }} {{ user.1 }} {% endfor %} 

and mentioned in comments, unpacking tuples option:

{% username, post_count in top_5 %}     {{ username }} {{ post_count }} {% endfor %} 

Comments

Popular posts from this blog

javascript - How to synchronize the Three.js and HTML/SVG coordinate systems (especially w.r.t. the y-axis)? -

javascript - How do I find how many occurences are there of a highlighted string, and which occurence is it? -

java - Reading data from multiple zip files and combining them to one -