Issue
I am making a nested for loop in Jinja / Python Flask.
If I hard code the values, then it works fine. Am I missing something in the Jinja template?
<table class="table table-striped">
<tr>
{% for column in Columns %}
<td>{{ column }}</td>
{% endfor %}
</tr>
{% for row in rows %}
<tr>
{% for column in Columns %}
<td>{{ row.column }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
By the way, the output is nothing when it is not hardcoded.
Solution
Figured it out...
<table class="table table-striped">
<tr>
{% for column in Columns %}
<td>{{ column }}</td>
{% endfor %}
</tr>
{% for row in rows %}
<tr>
{% for column in Columns %}
<td>{{ row[column] }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>
The only changed needed was to change {{ row.column }}
to {{ row[column] }}
on line 11.
Answered By - Rupert
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.