urlpatterns = [
path('batch_delete', UserView.batch_delete_view, name='batch_delete'),
]
<form method="post" action="update/{{ user.id }}/">
{% csrf_token %}
{% for user in users %}
<tr>
<td>
{{ user.id }}
</td>
<td>
<label>{{ user.name }}</label>
</td>
<td>{{ user.created_at }}</td>
<td>{{ user.updated_at }}</td>
<td>
<label><input type="checkbox" name="batch_ids[]" value="{{ user.id }}">{{ user.id }}</label>
<input type="submit" name="batch_delete" value="一括削除" />
</td>
</tr>
{% endfor %}
</form>
<form method="post" action="insert_from_batch_delete">
{% csrf_token %}
名前 <input type="textbox" value="" name="username" />
<input type="submit" name="insert" value="登録" />
</form>
def batch_delete_view(request):
users = {
'users': AppUser.objects.all(),
}
return render(request, 'batch_delete.html', users)