Reputation: 1
In my template i have a multiple-choice-object like this:
<form action="/hmi/give_trend3/" method="get">
<p>
<select name="n" size="3" multiple="multiple">
{% for tag in tags %}
<option>{{ tag.name }}</option><br>
{% endfor %}
</select>
</p>
</form>
and i want to get all the values (of the multiple-choice) in my views.py:
def give_trend3(request):
v = request.GET['v']
b = request.GET['b']
nn = request.GET['n'] ....
but in the value nn
I find only the last value of the choices.
How do I do that?
Upvotes: 0
Views: 1078
Reputation: 6828
Try this,
vals = request.GET.getlist("n", '')
Also bind the id to the options in your template,
<select name="n" size="3" multiple="multiple">
{% for tag in tags %}
<option value="{{ tag.id }}">{{ tag.name }}</option><br>
{% endfor %}
</select>
Upvotes: 2