By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,663 Members | 762 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,663 IT Pros & Developers. It's quick & easy.

DJANGO HTML Multiple select

kaarthikeyapreyan
100+
P: 107
Inside my form tags of test.html i have this code

Expand|Select|Wrap|Line Numbers
  1. <select id="PairedSelectBox" name="target_objects" multiple size="15">
  2. <option value="MD_1">MD_1</option>
  3. <option value="MD_2">MD_2</option>
  4. <option value="MD_3" selected="selected">MD_3</option>
  5. <option value="C_1"selected="selected">C_1</option>
  6. </select>
  7.  
  8.  
in my views.py when i do

request.POST.getlist('target_objects')

it returns -> ['MD_1'] this is the option that is highlighted in the front end.
My expected result should return either all the tags or one's with selected attribute not just the highlighted one's.
Dec 14 '15 #1
Share this Question
Share on Google+
2 Replies


100+
P: 299
Have you tried getting an array of target objects? Something like the following should work:

Expand|Select|Wrap|Line Numbers
  1. request.POST.getlist('target_objects[]')
Dec 14 '15 #2

kaarthikeyapreyan
100+
P: 107
unfortunately yes and Django v1.8.5 returns a empty list if i try that option
Dec 15 '15 #3

Post your reply

Sign in to post your reply or Sign up for a free account.