django获取from表单multiple-select的值

html代码

1
2
3
4
5
6
7
8
9
10
11
<!--增加通知人-->
<div class="form-group">
<select id="notify_users" name="notify_users"
class="selectpicker show-tick form-control bs-select-hidden" data-name="通知人"
data-live-search="true" multiple="multiple" data-placeholder="请选择通知人:">
<option value="is-empty" disabled="" selected="selected">请选择通知人:</option>
{% for user_info in active_user %}
<option value="{{ user_info.username }}">{{ user_info.username }}</option>
{% endfor %}
</select>
</div>

后端代码

1
2
def func(request):
notify_users = request.POST.getlist('notify_users')

取值结果

1
notify_users<class 'list'>: ['user1', 'user2', 'user3', 'user4', 'user5']