视图.py
def setting(request):
followup_form = FollowupSettingsForm()
if request.method == 'POST':
followup_form = FollowupSettingsForm(request.POST)
if followup_form.is_valid():
followup = followup_form.save(commit=False)
""""""""""""
return render(request, 'setting.html',{'form':followup_form})
模型.py
class FollowupUser(models.Model):
user = models.ForeignKey(User, null=True)
name = models.CharField(' Followup name', max_length=100, null=True, blank=True)
phone_no = models.CharField('Followup phone', max_length=100, null=True, blank=True)
email = models.CharField('Followup email', max_length=100, null=True, blank=True)
设置.html
<div id="add_form" style="display:none">
<form id="form" method="post" action="." onsubmit="return form_validate()">{% csrf_token %}
<table width="100%">
<tr>
<td style="width:100px;">Name:</td><td>{{ form.name}}</td>
</tr>
<tr>
<td>Phone No:</td><td>{{ form.phone_no}}
</tr>
<tr>
<td>Email:</td><td>{{ form.email}}</td>
</tr>
</table>
<div style="width:180px;margin:20px 5px 0 10px" align="right">
<button style="margin-right:10px;" type="button" class="close" name="cancel" class="forward backicon">Cancel</button>{% include "buttons/save.html" %}
</div>
</form>
</div>
我正在使用这个弹出窗口从用户那里获取数据并保存它。模板内的上面的div是弹出代码。上面的views.py是在数据库中插入数据。
我在 UI 中将保存的数据显示为名称(作为按钮),电子邮件 ID。
我在名称按钮中将表 id 作为 id 传递。单击名称按钮时,我想根据按钮中的 id 从 db 中获取数据并显示在弹出窗口中。如果我单击保存按钮,更改会在数据库中更新。我不知道如何使用 popup 更新数据。需要帮助才能做到这一点。
谢谢