title: (still unAnswered) django checkbox save yes or no in the database
body: <pre><code>  &lt;form id="form" name="form"&gt;
      &lt;input type="checkbox" value="1" name="Asthma" data-form-field="Option" class="form-check-input display-7" id="checkbox1"  title="Check if Student have Asthma"&gt;
      &lt;input type="checkbox" value="1" name="Congenital" data-form-field="Option" class="form-check-input display-7" id="checkbox1" title="Check if Student have Congenital Anomalies"&gt;
      &lt;input type="checkbox" value="1" name="Contact" data-form-field="Option" class="form-check-input display-7" id="checkbox1" title="Check if Student use Contact lens"&gt;
    &lt;/form&gt;
  </code></pre>
  
  <p>i have this code in my html</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
                          // when page is ready
                          $(document).ready(function() {
                               // on form submit
                              $("#form").on('submit', function() {
                                  // to each unchecked checkbox
                                  $(this + 'input[type=checkbox]:not(:checked)').each(function () {
                                      // set value 0 and check it
                                      $(this).attr('checked', true).val(0);
                                  });
                              })
                          })
                      &lt;/script&gt;
  </code></pre>
  
  <p>my problem is everytime i save into my database the result always automatic YES, even i unchecked the checkbox(NO) in the html.
  i dont know if i am doing right in my javascript</p>
  
  <p>this is my views.py</p>
  
  <pre><code>    Asthma = request.POST['Asthma']
      Congenital = request.POST['Congenital']
      Contact = request.POST['Contact']
  V_insert_data = StudentUserMedicalRecord( 
          Asthma=Asthma,
          CongenitalAnomalies=Congenital,
          ContactLenses=Contact
     )
   V_insert_data.save()
  </code></pre>
  
  <p>models.py</p>
  
  <pre><code>Asthma=models.BooleanField(null=True, blank=True, default=False)
  CongenitalAnomalies=models.BooleanField(null=True,blank=True, default=False)
  ContactLenses=models.BooleanField(null=True,blank=True, default=False)
  </code></pre>
  
  <p>html.py
  <a href="https://i.stack.imgur.com/sxDur.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sxDur.png" alt="enter image description here"></a></p>
  
  <p>even i insert record from my html is unchecked(No), the  result always automatic "Yes" in my database, can you please fixed my javascript code? seems like its not working.</p>
  
  <p><a href="https://i.stack.imgur.com/HyHQB.png" rel="noreferrer"><img src="https://i.stack.imgur.com/HyHQB.png" alt="enter image description here"></a></p>