lundi 16 mars 2015

Jinja2 Accessing an specific index in List of Lists


Vote count:

0




I'm new to Jinja and Python and having trouble getting my table to print out. I had something like this working and generating a table (though it would always miss index 0).



<table>
{% for row in table %}
<tr>
{% for cell in row %}
<td>{{ cell }}</td>
{% endfor %}
</tr>
{% endfor %}
</table>


But I want to move to something like this so I can apply individual characteristics to different columns. One column will be links, one blue, etc. Though this code just gives me a bunch of blank <td></td> lines. Am I not accessing the index correctly?



<table>
{% for row in table %}
<tr>
<td>{{ row[0] }}</td>
<td>{{ row[1] }}</td>
<td>{{ row[2] }}</td>
<td>{{ row[3] }}</td>
<td>{{ row[4] }}</td>
<td>{{ row[5] }}</td>
<td>{{ row[6] }}</td>
<td>{{ row[7] }}</td>
<td>{{ row[8] }}</td>
</tr>
{% endfor %}
</table>


asked 3 mins ago







Jinja2 Accessing an specific index in List of Lists

Aucun commentaire:

Enregistrer un commentaire