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.
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.
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.
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”))
@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.