I have a problem: I want to make checkboxes of each line of table:
<form action="" method="post">
{% csrf_token %}
<table>
<thead>
<tr>
<th>cb</th>
<th width="150">first_col</th>
<th>sec_col</th>
<th width="150">third_col</th>
</tr>
</thead>
<tbody>
{% for i in list %}
<tr>
<td><input type="checkbox" name="choices" value="{{i.id}}"></td>
<td>{{ i.created_date}}</td>
<td><a href="/{{i}}/"> {{ host }}/{{i}}/ </a></td>
<td>{{i.number_of_clicks}}</td>
</tr>
{% endfor %}
</tbody>
</table>
<button type="submit" name="delete" class="button">Del</button>
</form>
And in the def
I make next in order to check if it works:
if 'delete' in request.POST:
for item in request.POST.getlist('choices'):
print (item)
But it does not print anything... What do i do wrong? Or can you help me to write correct handler of checkboxes?
Aucun commentaire:
Enregistrer un commentaire