I'm trying to display values from a different list based on the index that is currently being iterated over on another list but cannot figure out how to access the individual items..
{% for row in myarray.all %}
<tr>
<th>{{ my_other_array_where_I_cant_access_elements.forloop.counter }}</th>
<td>{{ row }}</td>
</tr>
{% endfor %}
As you can see I have tried to use forloop.counter
but this doesn't display anything, it just creates an empty table header element.
My other array is defined within the view as the following, and if I remove the forloop.counter
then I am able to see the entire array printed to the table header
my_other_array_where_I_cant_access_elements = ["X", "Y", "Z", "XX", "YY"]
Please let me know if I've missed any required details.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…