我想使用多个复选框更新数据 这是我的视图.py你知道吗
def update_kel_stat(request, id):
if request.method == "POST":
cursor = connection.cursor()
sql = "UPDATE keluargapeg_dipkeluargapeg SET KelStatApprov='3' WHERE (PegUser = %s )" % id
cursor.execute(sql)
这是我的模板.html你知道吗
<form method="post" action="" name="kel" enctype="multipart/form-data">
{% for keluarga in kels %}
<tr id="{{ keluarga.KelID }}">
<td>
<a href="#">{{ keluarga.KelNamaLengkap }}</a>
</td>
<td>{{ keluarga.KelStatApprov }}</td>
<td>{{ keluarga.KelKetRevisi }}</td>
<td><input type="checkbox" name="kel[]"
value="{{ keluarga.KelID }}"></td>
</tr>
{% endfor %}
<tr>
<td>
<button type="button" name="btn_delete" id="btn_delete"
class="btn btn-success"
onClick="setDeleteAction();">Approve
</button>
</td>
</tr>
</form>
如何从中的复选框中获取多个值模板.html去django查看.py?你知道吗
首先,对于这样简单的查询,不建议使用原始SQL。使用django ORM更新某些记录非常容易:
至于你的问题,你可以这样做。在模板中:
在你看来:
相关问题 更多 >
编程相关推荐