title: Django forms.MultipleChoiceField with CheckboxSelectMultiple and Bootstrap custom-control-input is reset when form.is_bound
body: <p>I have a form field:</p>
  <p>Forms.py</p>
  <pre><code>colors = forms.MultipleChoiceField(
          required=True,
          widget=forms.CheckboxSelectMultiple,
          choices= [(1,'blue'),(2,'red'),(3,'green')]
      )
  </code></pre>
  <p>I can easily render this field like this:</p>
  <p>Template.html</p>
  <pre><code>{{ form.colors }}
  </code></pre>
  <p>And get something that looks like this:</p>
  <p><a href="https://i.stack.imgur.com/OVUr6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OVUr6.png" alt="enter image description here" /></a></p>
  <p>So the html code looks like that:</p>
  <pre><code>&lt;ul id=&quot;id_colors&quot;&gt;
      &lt;li&gt;&lt;label for=&quot;id_colors_0&quot;&gt;&lt;input type=&quot;checkbox&quot; name=&quot;colors&quot; value=&quot;1&quot; id=&quot;id_colors_0&quot; checked=&quot;&quot;&gt;
   blue&lt;/label&gt;
  
  &lt;/li&gt;
      &lt;li&gt;&lt;label for=&quot;id_colors_1&quot;&gt;&lt;input type=&quot;checkbox&quot; name=&quot;colors&quot; value=&quot;2&quot; id=&quot;id_colors_1&quot; checked=&quot;&quot;&gt;
   red&lt;/label&gt;
  
  &lt;/li&gt;
      &lt;li&gt;&lt;label for=&quot;id_colors_2&quot;&gt;&lt;input type=&quot;checkbox&quot; name=&quot;colors&quot; value=&quot;3&quot; id=&quot;id_colors_2&quot;&gt;
   green&lt;/label&gt;
  
  &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  <p>This is really simple ! And it's working fine.</p>
  <p>Now, let's say I want to render this differently, exactly like this:</p>
  <p><a href="https://i.stack.imgur.com/edzKZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/edzKZ.png" alt="enter image description here" /></a></p>
  <p>With bootstrap custom-control-input.</p>
  <p>Bootstrap documentation show this code to achieve this:</p>
  <pre><code>  &lt;div class=&quot;custom-control custom-checkbox&quot;&gt;
      &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; id=&quot;customCheck&quot; name=&quot;example1&quot;&gt;
      &lt;label class=&quot;custom-control-label&quot; for=&quot;customCheck&quot;&gt;Check this custom checkbox&lt;/label&gt;
    &lt;/div&gt;
  </code></pre>
  <p>So, in my template I did something like that:</p>
  <p>Template.html</p>
  <pre><code>&lt;div class=&quot;custom-checkbox&quot;&gt;
      &lt;ul id=&quot;id_colors&quot;&gt; 
          {% for key, value in colors %}
              &lt;li&gt;
              &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; value=&quot;{{key}}&quot; name=&quot;colors&quot; id=&quot;id_colors_{{ forloop.counter0 }}&quot;&gt;
              &lt;label class=&quot;custom-control-label&quot; for=&quot;id_colors_{{ forloop.counter0 }}&quot;&gt;{{value}}&lt;/label&gt;
              &lt;/li&gt;
          {% endfor %}
      &lt;/ul&gt;
  &lt;/div&gt;
  </code></pre>
  <p>(Where &quot;colors&quot; is just my list that I pass to the template thru the view)</p>
  <p>With that template, the field looks exactly like I want.
  When rendered, the html looks like this:</p>
  <pre><code>&lt;ul id=&quot;id_colors&quot;&gt;              
          &lt;li&gt;
          &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; value=&quot;1&quot; name=&quot;colors&quot; id=&quot;id_colors_0&quot;&gt;
          &lt;label class=&quot;custom-control-label&quot; for=&quot;id_colors_0&quot;&gt;blue&lt;/label&gt;
          &lt;/li&gt;
      
          &lt;li&gt;
          &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; value=&quot;2&quot; name=&quot;colors&quot; id=&quot;id_colors_1&quot;&gt;
          &lt;label class=&quot;custom-control-label&quot; for=&quot;id_colors_1&quot;&gt;red&lt;/label&gt;
          &lt;/li&gt;
      
          &lt;li&gt;
          &lt;input type=&quot;checkbox&quot; class=&quot;custom-control-input&quot; value=&quot;3&quot; name=&quot;colors&quot; id=&quot;id_colors_2&quot;&gt;
          &lt;label class=&quot;custom-control-label&quot; for=&quot;id_colors_2&quot;&gt;green&lt;/label&gt;
          &lt;/li&gt;
      
  &lt;/ul&gt;
  </code></pre>
  <p>So everything is working fine !</p>
  <p>Yes, except that, if I submit the form, and it is not validated (form.is_bound), the checked checkbox are going to be reset.</p>
  <p>If I do not apply the custom-control-input style, and render this field in a simple way, I do not have this problem...</p>
  <p>If you guys have any idea how to fix that.</p>