[Fixed]-Get checkbox value in django

1👍

From what I know, if you give every input checkbox the same name, you can refer to the them as a list in your views.py.

So in the template:

{% for name in list_exp %}
   <input type="checkbox" name="list_exp"><label> Experiment : {{name}}</label>
   <br>
{% endfor %}

And then in the views.py:

request.POST.getlist('list_exp')

will return a list as expected

👤zubhav

Leave a comment