[Django]-Django: using <select multiple> and POST

195👍

request.POST.getlist('services')

17👍

Just FYI, I had to use:

    list = request.POST.getlist("items[]")

because omitting the [] caused a blank list to be returned instead of the correct values. I’m using jQuery to fetch the values of a multiple select element, and jQuery appears to be adding the []

2👍

you can get the expected list just by using…

request.POST.getlist('fiel_name')
👤Javed

1👍

Watch out! getlist method from QueryDict returns an empty list if the key doesn’t exist. It does not throw an exception. http://bit.ly/MdgrUH

👤ady

1👍

request.POST.getlist(‘services’)

Worked for me. or you can define select box name as a list

Leave a comment