DJANGO HTML Multiple select

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kaarthikeyapreyan
    New Member
    • Apr 2007
    • 106

    DJANGO HTML Multiple select

    Inside my form tags of test.html i have this code

    Code:
    <select id="PairedSelectBox" name="target_objects" multiple size="15">
    <option value="MD_1">MD_1</option>
    <option value="MD_2">MD_2</option>
    <option value="MD_3" selected="selected">MD_3</option>
    <option value="C_1"selected="selected">C_1</option>
    </select>
    in my views.py when i do

    request.POST.ge tlist('target_o bjects')

    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.
  • Luk3r
    Contributor
    • Jan 2014
    • 300

    #2
    Have you tried getting an array of target objects? Something like the following should work:

    Code:
    request.POST.getlist('target_objects[]')

    Comment

    • kaarthikeyapreyan
      New Member
      • Apr 2007
      • 106

      #3
      unfortunately yes and Django v1.8.5 returns a empty list if i try that option

      Comment

      Working...