lundi 29 juin 2015

Django : HTML Table with iterative lists values

I am using Django framework and trying to build a table based on the values i have in a list:

list : [[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12], [3, 3, 3, 3]] The table should be as shown below:

The code I have used is :

  html = "<html><body><br>" \
           "<table border=1 ><thead> <tr><th>result 1</th><th>result 2</th><th>result 3</th><th>result 4</th></tr><thead>{% for item in matrix %} {% for secitem in item %} <tr> <td> {{secitem[0]}} </td>  <td> {{secitem[1]}} </td><td> {{secitem[2]}} </td><td> {{secitem[3]}} </td>  </tr>    {% endfor %}{% endfor %} " \
           "</table></body></html>"

I am not able to get the exact table with the required rows in it. Any help is highly appreciated.![enter image description here][1]

Aucun commentaire:

Enregistrer un commentaire