I have a table and in the table a form with fields the user can change. Three of these fields use check boxes. I'm able to reflect what is currently in the database after following this post, but I haven't been able to find something else for the next piece of the puzzle.
The problem I'm having is that if a checkbox is set to true(checked) and then I unselect it, the POST data does not include anything that says that it is not checked anymore. It doesn't give a value of "off", "0" or false. How can I make sure that when the boxes are unchecked I still get those values("off", 0" or "false")? on the post data?
Below is my code:
<form id=result_form action= "{% url 'example:save_notes' %}" method="post">
{% csrf_token %}
<table id="results_table" class="formdata" summary="Example Search Results"
data-order='[[ 1, "des" ]]' data-page-length='25'>
<thead>
<tr>
<th style="width:5%" scope="col">Search Method</th>
<th style="width:20%" scope="col">Search Date</th>
<th style="width:5%" scope="col">City</th>
<th style="width:10%" scope="col">Example Name</th>
<th style="width:10%" scope="col">Article Title</th>
<th style="width:10%" scope="col">Article Link</th>
<th style="width:5%" scope="col">Reviewed </th>
<th style="width:5%" scope="col">J/J Related</th>
<th style="width:5%" scope="col">N Related</th>
<th scope="col">General Notes</th>
<th scope="col">Findings</th>
<th scope="col">Edit</th>
</tr>
</thead>
<tbody>
{% for result in results %}
<tr>
<td>{{result.notes.method}}</td>
<td>{{result.retrieved_on}}</td>
<td>{% for e in result.search_result_t.all%}{{e.search_term_id.example_abbrev}} {% endfor %}</td>
<td>{% for e in result.search_result_t.all%}{{e.search_term_id.example_ID.example_name}}{% endfor %}</td>
<td>{{result.title}}</td>
<td width="5%"><a href={{result.link}} target="_blank">{{result.link}}</a></td>
<form action="{% url 'example:form_edit' %}" method="POST">
<td><input type="checkbox" name="reviewed" {% if result.notes.reviewed %}checked{% endif %}></td>
<td><input type="checkbox" name="jj" {%if result.notes.j_j %}checked{% endif %}></td>
<td><input type="checkbox" name="n" {%if result.notes.n_related %}checked{% endif %}></td>
<td><textarea cols="40" rows="15" name="general_notes" value = "{{result.notes.general_notes}}">{{result.notes.general_notes | default_if_none:""}}</textarea>
<td><textarea cols="40" rows="15" name="significant_findings" value = "{{result.notes.significant_findings}}">{{result.notes.significant_findings | default_if_none:""}}</textarea>
<td><button>Save</button></td>
<input type="hidden" name="result.id" value={{result.id}}>
</form>
</tr>
{% endfor %}