Get checkbox value in django
<p>I have passed a python list (list_exp) in my html template and now i would like to get the result of my multiple checkbox in view.py with a dictionary.
{list_exp[0] : True/False, list_exp[1] : True/False.....}  </p>

<pre><code>&lt;form action="" method="post"&gt;
{% for name in list_exp%}
&lt;input type="checkbox" name="{{name}}"&gt;&lt;label&gt; Experiment : {{name}}&lt;/label&gt;
&lt;br&gt;
{% endfor %}
&lt;input type="submit" value="Submit"&gt;
&lt;/div&gt;
&lt;/form&gt;
</code></pre>

<p>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. </p>

<p>So in the template:</p>

<pre><code>{% for name in list_exp %}
   &lt;input type="checkbox" name="list_exp"&gt;&lt;label&gt; Experiment : {{name}}&lt;/label&gt;
   &lt;br&gt;
{% endfor %}
</code></pre>

<p>And then in the views.py:</p>

<pre><code>request.POST.getlist('list_exp')
</code></pre>

<p>will return a list as expected</p>

python django input submit