这是后端的代码
def sr(request):
bd = request.GET.get('b')
if bd:
obj = models.brown_plant_hopper_new.objects.filter(id=bd)
return render(request, 'sr_list3.html', {"obj": obj})
这是前端页面的代码
<form method="get">
<table class="table table-bordered">
<thead>
<tr>
<th>
<button class="btn btn-default" type="submit">比对</button>
</th>
<th>ID</th>
<th>年份</th>
<th>月份</th>
<th>姓名</th>
<th>实验环境</th>
</tr>
</thead>
<tbody>
<tr>
<td><input type="checkbox" name="b" value="{{ item.id }}"></td>
<td>{{ item.id }}</td>
<td>{{ item.year }}</td>
<td>{{ item.month }}</td>
<td>{{ item.name }}</td>
<td>{{ item.plot }}</td>
</tr>
</tbody>
</table>
</form>
在网上找答案说要将name="b"改为name="b[ ]",使用数组。但是我尝试过后发现页面并不跳转到'sr_list3.html'页面,而是停留在当前页面,url上显示b%5B%5D和选择的id。如果不加[ ],结果如标题所述,在'sr_list3.html'页面只显示最后一条记录,并且url为b以及选择的id。百度了下%5B%5D的意思就是[ ] 。
请问我这个是什么原因,还望不吝赐教,有帮助必采纳!!