0

How to save the selected options from a multi select drop down in a Django variable as a list ? Is there anything to be imported from the .html to .py?

1 Answers1

0

To get the values from multiple dropdown the method is:

Template(myPage.html):

<select multiple="multiple"  name="services" id="services" size="5">
    {% for service in services %}
        <option value="{{ service.pk }}">{{ service.name }}</option>
    {% endfor %}
</select>

Views(views.py):

myServices = request.POST.getlist('services')

good luck..!!

Diego Avila
  • 700
  • 7
  • 24