Django – How to do tuple unpacking in a template ‘for’ loop

Another way is as follows.

If one has a list of tuples say:

mylst = [(a, b, c), (x, y, z), (l, m, n)]

then one can unpack this list in the template file in the following manner.
In my case I had a list of tuples which contained the URL, title, and summary of a document.

{% for item in mylst %}    
     {{ item.0 }} {{ item.1}} {{ item.2 }}    
{% endfor %}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)