Django - How to split my objects between days dynamically
I have a list of days and exercises that are created based on a form input. When I try to load the exercises on the template, all exercises repeat on every day. However, I want them to be split to 6 exercises on every day. I can do it by using split, and even make my own filters, but it doesn't work dynamically. And since the number of days and exercises can vary depending on the form input, I need a dynamically way to figure it out.
<form>
<div>
<table class="table">
<thead>
<tr>
{% for week in weeks %}
<th></th>
<th colspan="3">{{week}}</th>
{% endfor %}
</tr>
</thead>
<tbody>
{% for day in days %}
<tr>
{% for week in weeks %}
<td></td>
<td colspan="2">{{day}}</td>
<td><input type="text" class="form-control" /></td>
{% endfor %}
</tr>
<tr>
<td>Exercise</td>
{%for week in weeks %}
<td>Set</td>
<td>Weight</td>
<td>Reps</td>
{% endfor %}
</tr>
{% for exercise in exercises %}
<tr>
<td rowspan="3">{{exercise}}</td>
{%for week in weeks %}
<td>1</td>
<td><input type="text" class="form-control" value="" /></td>
<td><input type="text" class="form-control" value="" /></td>
{% endfor %}
</tr>
<tr>
{%for week in weeks %}
<td>2</td>
<td><input type="text" class="form-control" value="" /></td>
<td><input type="text" class="form-control" value="" /></td>
{% endfor %}
</tr>
<tr>
{%for week in weeks %}
<td>3</td>
<td><input type="text" class="form-control" value="" /></td>
<td><input type="text" class="form-control" value="" /></td>
{% endfor %}
</tr>
{% endfor %}
{% endfor %}
</tbody>
</table>
</div>
</form>
I feel like I'm just placing the tags on the wrong place, and when "day" is being looped it just repeat the rest of the code, so no matter which filter I use the issue won't be solved dynamically.