I need to create a custom table in django template as below:
<table>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td>
</td>
<td>
</td>
</tr>
</table>
i.e I want to add new tr tag after every 3 td tags. I tried applying logic using {{forloop.counter|divisibleby:4}}. I tried something like below but it didn't generated desired results.
{% for items in range(5) %}
{% if forloop.counter ==1 or forloop.counter|divisibleby:4 %}\
<tr>
{% endif %}
<td>name</td>
{% if forloop.counter|divisibleby:4 %}
</tr>
{% endif %}
</tr>
{% endfor %}
but it is obviously not correct solution.
Update:
It is generating something like below:
Where each image is td tag