A method that is recommended by most of people:
files_form_checked_chkbox = request.POST.getlist("file_of_chkbox")
for every_file in files_form_checked_chkbox:
#do somethig
This is B method that I find:
keys = request.POST.keys()
for key in keys:
if key != "csrfmiddlewaretoken":
#do somethig
This is my template:
<p>List</p>
<form action="..." method="post">
{% csrf_token %}
{% for key in keys %}
<p>
<input type="checkbox" name="file_of_chkbox" value="{{key}}">
<a href="..." >{{key}}</a>
</p>
{% endfor %}
<input type="submit" value="Delete files" />
</form>
Both methods can do same thing.
I see. It's sure that A is better than B and A is explained many time. I use request
But I want to understand why B is't recommended with reson.