Форма post request не отправляет данные в django views.py. пожалуйста, помогите мне

я передаю данные из edisplay.html в views.py имя класса EmailManagement, но после вставки данных данные становятся пустыми, даже если я их ввожу, и я упал в автозагрузку, когда я ввожу первую форму, потому что моя форма появляется только при валидации первой формы. First condition then only other will display

Second form

Termainal where can see blank value

views.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})

edisplay.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>

models.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

pform.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()
    
    

Мне нужно пройти через первую форму, чтобы отобразить вторую форму. прошу помощи, пожалуйста, помогите мне.

пустое значение - значение NULL или пустое значение

Вернуться на верх