I need help with form which looks like a Gmail inbox and have multiple actions. There is a list of items and I want to wrap it with form, on the way that every item have checkbox in the front of the line. So when user select few items he is able to click on two buttons with different actions for example delete and mark read.
<form action="">
{% for item in object_list %}
<input type="checkbox" id="item.id">
{{ item.name }}
{% endfor %}
<button type="submit" name="delete">Delete</button>
<button type="submit" name="mark_read">Mark read</button>
</form>
I can find which submit button is user click on if use if 'delete' in request.POST but I cant refer to any form because Django form cant be defined with unknown number of fields as I think. So how can I process selected items in view?
if request.method == 'POST':
form = UnknownForm(request.POST):
if 'delete' in request.POST:
'delete selected items'
if 'mark_read' in erquest.POST:
'mark selected items as read'
return HttpResponseRedirect('')