我正在从选中的复选框获取值列表,现在我想用我的模型过滤列表,而只获取列表中值的过滤结果
views.py
def ResultTest(request):
var = request.POST.get('selectedTests')
var1 = BookTest.objects.filter(test=v)
return render(request, 'posts/result.html',{'var1':var1})
html file
<div class="col-md-12" style="overflow: auto;">
<input type="hidden" id="selectedTests" name="selectedTests">
<input type="hidden" name="test_type" value="pathology">
<table id="example" class="display" >
<thead>
<tr>
<th>Sr.No</th>
<th>Select</th>
<th>Test</th>
<th>MRP</th>
<th>CC Rate</th>
</tr>
</thead>
<tbody>
{% for booktest in contact_list %}
<tr>
<td>{{ booktest.number }}
<td><input type="checkbox" name="check_list[]" value="{{ booktest.test }}" class="chkbox"/> </td>
<td>{{ booktest.test }}</td>
<td>{{ booktest.mrp }} </td>
<td>{{ booktest.rate }}</td>
</tr>
{% endfor %}
</tbody>
</table>
我正在获取selectedTests值列表,现在我希望值列表在模型中过滤并获取值的所有数据。
您可以尝试用逗号分隔值: