django获取from表单multiple-select的value和id的方法
如下所示:
{%foropinhost_list%} {{op.hostname}} {%endfor%}
1、当需要获取选中的option的value时,
需设置为id="{{op.nid}}",
djangoViews获取选中的值为host_value=request.POST.getlist("host_list")
获取的为选中的option的value;
2、当需要获取选中的option的id时,
需设置为value="{{op.nid}}",
djangoViews获取选中的值为host_id=request.POST.getlist("host_list")
获取的为选中的option的id;
以上这篇django获取from表单multiple-select的value和id的方法就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持毛票票。