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 []
- [Django]-Request.POST.get('sth') vs request.POST['sth'] – difference?
- [Django]-How do you perform Django database migrations when using Docker-Compose?
- [Django]-Querying django migrations table
- [Django]-Django gives Bad Request (400) when DEBUG = False
- [Django]-How to get primary keys of objects created using django bulk_create
- [Django]-Django fix Admin plural
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
- [Django]-How to express a One-To-Many relationship in Django?
- [Django]-Django model blank=False does not work?
- [Django]-Define css class in django Forms
1👍
request.POST.getlist(‘services’)
Worked for me. or you can define select box name as a list
- [Django]-How to write django test meant to fail?
- [Django]-Django – accessing the RequestContext from within a custom filter
- [Django]-Django – FileField check if None
Source:stackexchange.com