gpt4 book ai didi

python - 我如何从 django 中的 mysql 检索数据并以模式显示,其中我也可以更新它?

转载 作者:行者123 更新时间:2023-11-29 15:31:05 27 4
gpt4 key购买 nike

我需要做的是单击 View 模式按钮后,它将显示信息,然后还有一个按钮可以更新它。有人可以建议我哪一个是最好的事情吗?谢谢。模型.py

class Employee(models.Model):
first_name = models.CharField(max_length=100, blank=True, null=True)
last_name = models.CharField(max_length=100, blank=True, null=True)
middle_name = models.CharField(max_length=100, blank=True, null=True)
userid = models.CharField(max_length=45, blank=True, null=True)
email_address = models.CharField(max_length=100, blank=True, null=True)

我还没有views.py(不知道从哪里开始)

模态代码:

{% for employee in employees %}

<div class="modal fade" id="employee.employee_id_{{ employee.employee_id }}" tabindex="-1" role="dialog" style="display: none; overflow: auto;" aria-hidden="true" data-backdrop="static">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" >Employee</h5>
<button type="button" class="close" modalid="referral_modal" id="close_referral" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body" style="overflow: auto">
<div class="col-md-15">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-md-12">
<h4>Your Profile</h4>
<hr>
</div>
</div>
<div class="row">
<div class="col-md-12">
<form>
<div class="form-group row">
<label for="username" class="col-4 col-form-label">User Name*</label>
<div class="col-8">
<input id="username" name="username" placeholder="{{ employee.userid}}" class="form-control here" required="required" type="text">
</div>
</div>
<div class="form-group row">
<label for="name" class="col-4 col-form-label">First Name</label>
<div class="col-8">
<input id="name" name="name" placeholder="{{ employee.first_name}}" class="form-control here" type="text">
</div>
</div>
<div class="form-group row">
<label for="text" class="col-4 col-form-label">Middle Name*</label>
<div class="col-8">
<input id="text" name="text" placeholder="{{ employee.middle_name}}" class="form-control here" required="required" type="text">
</div>
</div>
<div class="form-group row">
<label for="lastname" class="col-4 col-form-label">Last Name</label>
<div class="col-8">
<input id="lastname" name="lastname" placeholder="{{ employee.last_name}}" class="form-control here" type="text">
</div>
</div>
<div class="modal-footer">
<button name="submit" type="submit" class="btn btn-primary">Update</button>
<button type="button" class="btn btn-secondary" data-dismiss="modal" onclick="">Cancel</button>
</div>

</div>
</div>
</div>
</div>
</div>
{% endfor %}
{% endblock %}

MySQL DB

最佳答案

您可以将标记设置为只读。例子:

然后在 javascript 中单击“更新按钮”,您可以使其再次可编辑。document.getElementById("name").readOnly = false;

关于python - 我如何从 django 中的 mysql 检索数据并以模式显示,其中我也可以更新它?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58722751/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com