# reading multiple selection from checkbox fields

**URL:** <https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036>\
**Category:** Forms & APIs\
**Created:** [February 22, 2023, 3:21pm UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036 "2023-02-22T15:21:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gezamboni](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gezamboni/32/12348_2.png) [@gezamboni](https://forum.djangoproject.com/u/gezamboni)\
**Post date:** [February 22, 2023, 3:21pm UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/1 "2023-02-22T15:21:41Z")

</div>

II have a form (poll) with some questions and each question can have two or more answers available. When I try to collect the answers sxelected in the checked boxes using response.POST I receive back a QueryDict with the choices selected but I can`t read them.

Please how do I do to get the choices selected?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [February 22, 2023, 3:23pm UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/2 "2023-02-22T15:23:57Z")

</div>

If you’re using a Django form, you don’t need to interrogate `response.POST` - Django will have populated your form field with the selections that were made.

---

<div class="post-metadata">

**Author:** ![gezamboni](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gezamboni/32/12348_2.png) [@gezamboni](https://forum.djangoproject.com/u/gezamboni)\
**Post date:** [February 22, 2023, 3:32pm UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/3 "2023-02-22T15:32:31Z")

</div>

Thanks Ken, I’ll try using Django Forms.

---

<div class="post-metadata">

**Author:** ![var1285](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/var1285/32/12295_2.png) [@var1285](https://forum.djangoproject.com/u/var1285)\
**Post date:** [February 23, 2023, 12:01pm UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/4 "2023-02-23T12:01:32Z")

</div>

To get the choices selected from a form with multiple checkboxes, you can use the `getlist()` method of the QueryDict object returned by `request.POST` . The `getlist()` method returns a list of values for a given key.

---

<div class="post-metadata">

**Author:** ![gezamboni](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/gezamboni/32/12348_2.png) [@gezamboni](https://forum.djangoproject.com/u/gezamboni)\
**Post date:** [February 23, 2023, 4:27pm UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/5 "2023-02-23T16:27:30Z")

</div>

Hi Varsha, Thank you very much for your answer. It really worked.  
I’ve also tested Ken’s answer and it worked too.  
Thank you both for the help.

---

<div class="post-metadata">

**Author:** ![DevCoder1309](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/devcoder1309/32/14319_2.png) [@DevCoder1309](https://forum.djangoproject.com/u/DevCoder1309)\
**Post date:** [June 19, 2023, 8:22am UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/6 "2023-06-19T08:22:51Z")

</div>

Hello sir i am facing a little different issue,  
i am getting an empty list. Could please tell me what is wrong here,  
{% for x in content %}  
  
&nbsp;  
{{x.0}}  
{{x.1}}  
{{x.2}}

```
  <td style="background-color: white; border:1px solid white"><div class="form-check">
    <input
      type="checkbox"
      name="tag[]"
      value="{{x}}"
    />
  </div></td>
</tr>
{% endfor %}

```

and in views.py this fucktion i am calling when checked  
def remove(request):  
check\_values = request.POST.getlist(‘tag’)  
print(check\_values)  
# for i in check\_values:  
# check\_values.remove(i)  
return HttpResponseRedirect(reverse(“tasks:index”))

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [June 19, 2023, 11:54am UTC](https://forum.djangoproject.com/t/reading-multiple-selection-from-checkbox-fields/19036/7 "2023-06-19T11:54:49Z")

</div>

@DevCoder1309 - I suggest you open a new topic for your issue.

Note: When posting code, templates, error messages here, surround the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted.
