I have a html form that looks like this.
{% url 'myapp:myapp_submit' as submit %}
<form name='main' method="POST" action={{submit}}>
{% csrf_token %}
<select class='form-control' size=10 id="test" name='test' multiple>
<option>Test</option>
</select>
<input type="submit"/>
</form>
and url.py
from . import views
app_name = 'myapp'
urlpatterns = [
url(r'^$', views.myapp, name='myapp'),
url(r'results/$', views.myapp_submit, name='myapp_submit')
]
and views.py
def myapp_submit(request):
print request.POST
The only thing I get back is
<QueryDict: {u'csrfmiddlewaretoken'...]}>
How do I get back the options held in the select tag? I would use the model/view form here but I'm doing some very crazy things with JS to constantly update the options available.
UPDATE
I have used:
request.POST.getlist('test')
But it will only return ['Test'] If I highlight it with my mouse. I simply want all the options under the select tag. ex.
<select class='form-control' size=10 id="test" name='test' multiple>
<option>Test1</option>
<option>Test2</option>
<option>Test3</option>
<option>Test4</option>
</select>
and
###Not sure if it's still getlist method
>>request.POST.getlist('test')
['Test','Test2','Test3','Test4']