How do I get the values of all selected checkboxes in a Django request.POST?

前端 未结 2 1218
感情败类
感情败类 2020-12-12 17:53

Hi I have an array of checkboxes e.g.




        
相关标签:
2条回答
  • 2020-12-12 18:37

    Try this:

    some_var = request.POST.getlist('checks')
    

    some_var will contain [1,3,4] (those values that were checked)

    0 讨论(0)
  • 2020-12-12 18:41

    This will fix your problem,

    some_var = request.POST.getlist('checks[]')
    

    If you write some_var = request.POST.getlist('checks') may not work properly.

    0 讨论(0)
提交回复
热议问题