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 - ScrollTo Effect (href to div) -

javascript - ng-class not responding to change in model in Angular? -

javascript - document.registerElement extending HTMLInputElement prototype while using custom tag name to avoid implicit browser style -