我正在将数据从edisplay.html传递到www.example.com类名为EmailManagement,但插入数据后,即使我键入数据,数据也会变为空白,并且当我键入第一个表单时,我会自动提交,因为myform只出现在第一个表单验证中。views.py class name called EmailManagement but after inserting data data goes blank even I type it and I fell auto submitted when I type first form because myform appear only first form validation.
- 查看次数. py**
@csrf_exempt
def EmailManagement(request):
if request.method == "POST":
code = request.POST.get('scode_no', '')
if code:
userlogin = EmailDb.objects.all().filter(scode = code)
scode = ''
for i in userlogin:
scode += i.scode
# print(scode)
if code == scode:
sem = EmailDb.objects.all().filter(scode = code)
idv = ''
for i in sem:
idv += str(i.id)
print(idv)
idv = int(idv)
p = EmailDb.objects.get(id=idv)
if request.method == 'POST':
institution = request.POST.get('institutionf', '')
fullname = request.POST.get('fullnamef', '')
email = request.POST.get('personalef', '')
contact = request.POST.get('contactf', '')
position = request.POST.get('positionf', '')
uploaded = request.FILES.get('filef', '')
print(uploaded)
print(fullname)
p.institution = institution
p.fullname = fullname
p.contact = contact
p.email = email
p.position = position
p.uploaddata = uploaded
p.save(update_fields=['institution', 'fullname', 'contact', 'email', 'position', 'uploaddata'])
form = pForm()
return render(request, 'NEC/edisplay.html', {'p': p, 'form': form})
form = ResultForm()
return render(request,'NEC/emailmgt.html', {'form': form})
- 电子显示器. html**
<form hx-post="email" hx-target="body" method="POST" enctype="multipart/form-data">
{% csrf_token %}
{{p.useremail}}here
<!-- <input type="text" name="institution" id="institution" placeholder="Institution Name" class="form-control w-50 form-row" value="{{p.institution}}" required>
<input type="text" name="fullname" id="fullname" placeholder="Full Name" class="form-control w-50 form-row mt-1" value="{{p.fullname}}" required>
<input type="text" name="email" id="contact" placeholder="Personal Email " class="form-control w-50 form-row mt-1" value="{{p.email}}" required>
<input type="text" name="contact" id="contact" placeholder="Contact " class="form-control w-50 form-row mt-1" value="{{p.contact}}" required>
<input type="text" name="position" id="position" placeholder="Position " class="form-control w-50 form-row mt-1" value="{{p.position}}" required>
<input class="form-control w-50 form-row mt-1" type="file" id="formFile" name="upload" required> -->
{{form.as_p}}
<input class="form-check-input" type="checkbox" value="" id="invalidCheck" name='checkbox' required>
<label class="form-check-label" for="invalidCheck">
Agree to terms and conditions
</label>
<br>
<input class="bg-success text-white mt-1" style="margin-top: 0px;" type="submit" />
</form>
- 型号. py**
class EmailDb(models.Model):
institution = models.CharField(max_length=300, blank=True, null=True)
fullname = models.CharField(max_length=50, blank=True, null=True)
contact = models.CharField(max_length=50,blank=True, null=True)
email = models.CharField(max_length=300, blank=True, null=True)
position = models.CharField(max_length=100, blank=True, null=True)
uploaddata = models.FileField(upload_to='appointment_letter', blank=True, null=True)
useremail = models.CharField(max_length=100, blank=True, null=True)
userpassword = models.CharField(max_length=100, blank=True, null=True)
scode = models.CharField(max_length=200, blank=True, null=True)
def __str__(self):
return self.scode
- 形式py**
from django import forms
class pForm(forms.Form):
institutionf = forms.CharField(label="", help_text="", widget=forms.TextInput(attrs={'placeholder': 'Institution Name'}))
fullnamef = forms.CharField(label="", help_text="", widget=forms.TextInput(attrs={'placeholder': 'Full Name'}))
personalef = forms.CharField(label="", help_text="", widget=forms.TextInput(attrs={'placeholder': 'Personal Email'}))
contactf = forms.CharField(label="", help_text="", widget=forms.TextInput(attrs={'placeholder': 'Personal Email'}))
positionf = forms.CharField(label="", help_text="", widget=forms.TextInput(attrs={'placeholder': 'Contact'}))
filef = forms.FileField()
我必须通过第一个形式,以显示第二个形式.
1条答案
按热度按时间qkf9rpyu1#
blank value - NULL值或空值