Django - POST get options from select
<p>I have a html form that looks like this.</p>

<pre><code>{% url 'myapp:myapp_submit' as submit %}

&lt;form name='main' method="POST" action={{submit}}&gt; 
{% csrf_token %}
&lt;select class='form-control' size=10 id="test" name='test' multiple&gt;
&lt;option&gt;Test&lt;/option&gt;
&lt;/select&gt;
&lt;input type="submit"/&gt;
&lt;/form&gt;
</code></pre>

<p><strong>and url.py</strong></p>

<pre><code>from . import views

    app_name = 'myapp'
    urlpatterns = [
        url(r'^$', views.myapp, name='myapp'),
        url(r'results/$', views.myapp_submit, name='myapp_submit')
    ]
</code></pre>

<p><strong>and views.py</strong></p>

<pre><code>def myapp_submit(request):
    print request.POST
</code></pre>

<p>The only thing I get back is </p>

<pre><code>&lt;QueryDict: {u'csrfmiddlewaretoken'...]}&gt;
</code></pre>

<p>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. </p>

<p><strong>UPDATE</strong></p>

<p>I have used:</p>

<pre><code>request.POST.getlist('test')
</code></pre>

<p>But it will only return ['Test'] If I highlight it with my mouse. I simply want all the options under the select tag. ex.</p>

<pre><code>&lt;select class='form-control' size=10 id="test" name='test' multiple&gt;
&lt;option&gt;Test1&lt;/option&gt;
&lt;option&gt;Test2&lt;/option&gt;
&lt;option&gt;Test3&lt;/option&gt;
&lt;option&gt;Test4&lt;/option&gt;
&lt;/select&gt;
</code></pre>

<p>and </p>

<pre><code>###Not sure if it's still getlist method
&gt;&gt;request.POST.getlist('test')
['Test','Test2','Test3','Test4']
</code></pre>

<p>Try to change your <code>views.py</code>:</p>

<pre><code>def myapp_submit(request):
    request.POST.getlist('test[]')
</code></pre>

python django