Antouil
Antouil

Reputation: 63

how to loop over all my List items and extract the value from each key?

this is what i am trying to do :

{% set count = 0 %}
{% for k,v in results_list[count].items() %}
   <td>{{ v }}</td>
{% set count = count + 1 %}
{% endfor %}

instead of doing it manually like this :

{% for k,v in results_list[0].items() %}
<td>{{ v }} </td>
{% endfor %}
{% for k,v in results_list[1].items() %}
<td>{{ v }} </td>
{% endfor %}

Upvotes: 0

Views: 43

Answers (1)

Rakesh
Rakesh

Reputation: 82785

looks like you need a nested loop.

Ex:

{% for i in results_list %}
    {% for k,v in i.items() %}
        <td>{{ v }} </td>
    {% endfor %}
{% endfor %}

Upvotes: 2

Related Questions