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
Post a Comment