【发布时间】:2015-01-07 15:46:49
【问题描述】:
我正在使用 Django 将一些数据输入到我的数据库中。输入数据后,我想对其进行编辑。现在,我正在尝试的是,用户不应该去任何其他页面来更改数据。所以我实现了一个在前端编辑文本的javascript方法。
如何在数据库中反映用户所做的更改?
相关代码如下:
<html>
{% csrf_token %}
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
</script>
<table id="table">
<tr>
<th>Name</th>
<th>Phone Number</th>
</tr>
{% for record in queryset %}
<tr>
<td onClick="clickable(this)"> {{record.first}} </td>
<td onClick="clickable(this)"> {{record.second}}</td>
</tr>
{%endfor%}
</table>
<script>
function clickable(ele)
{
var value = prompt("Enter the details");
if(value)
{
ele.id='edited'
ele.innerHTML = value;
//I want to send the request to my django view to edit the database here
//The data has been updated.
}
【问题讨论】:
标签: javascript jquery html django