Как добавить значения для проверенных строк
Приведенный ниже код печатает список учеников в Django в виде таблицы. Я хочу добавить имя текущего зарегистрированного аккаунта в колонку учителя в проверенной строке, когда нажимается кнопка 'Добавить учителя'. И я хочу, чтобы добавленные данные были отражены в БД.
<table id="student-list" class="maintable">
<thead>
<tr>
<th class="text-black text-center text-nowrap bg-secondary font-weight-bold sticky-top-custom">Name</th>
<th class="text-black text-center text-nowrap bg-secondary font-weight-bold sticky-top-custom">Register Date</th>
<th class="text-black text-center text-nowrap bg-secondary font-weight-bold sticky-top-custom">Age</th>
<th class="text-black text-center text-nowrap bg-secondary font-weight-bold sticky-top-custom">Sex</th>
<th class="text-black text-center text-nowrap bg-secondary font-weight-bold sticky-top-custom">Teacher</th>
<th class="text-black text-center text-nowrap bg-secondary font-weight-bold sticky-top-custom">Select</th>
</tr>
</thead>
<tbody>
{% for student in students %}
<tr>
<td>{{ student.name }}</td>
<td>{{ student.register_date|date:'Y-m-d' }}</td>
<td>{{ student.age }}</td>
<td>{{ student.sex }}</td>
<td>{{ student.teacher}}</td>
<td><input type="checkbox"></td>
</tr>
{% endfor %}
</tbody>
</table>
<input type="button" value="Add Teacher" class="addteacher">
</table>
<script>
$(function() {
$(document).on("click", ".addteacher", function() {
var getselectedvalues=$(".maintable input:checked").appendTo($(".maintable tbody").add(getselectedvalues));
})
});
</script>