在django后台中获取前台中checkbox中提交的值,判断项目是否被选中。
template端:
<form action="" method="POST"> <input type="checkbox" value="1" name="check_box_list"/>1 <input type="checkbox" value="2" name="check_box_list"/>2 <input type="checkbox" value="3" name="check_box_list"/>3 <input type="checkbox" value="4" name="check_box_list"/>4 <input type="submit" value="提交"> </form>
后台views.py中
#通过request.REQUEST.getlist取到list形式的提交结果 def getresult(request): check_box_list = request.REQUEST.getlist("check_box_list")
###注:本文为转载而来作为学习笔记, 点击查看原文
Hello. It's my first publication on this forum!