I am saving EmailDb field username and userpassword to another Emails models but it is saving null data in Emails db with refresh django

Null value or empty value saved with each refresh, even click button submit duplicate value, please find the following models and views file. please look at envlope button in the image that is submit button which create another model db called Emails.


{% for i in obj %}
                                {% if i.id %}
                            <th scope="row">{{forloop.counter0|add:obj.start_index}}</th>
                            <td><img src={{i.uploaddata.url}} class="img-fluid img-thumbnail" alt={{i.fullname}} style="width:100px; height: 60px"></td>
                                <a href="{% url 'update' i.id %}" class="btn btn-warning btn-sm"><i class="fa-regular fa-pen-to-square"></i></a>
                                <form action="{% url 'delete' i.id %}" method="POST" class="d-inline">
                                    {% csrf_token %}
                                  <button type="submit" class="btn btn-danger btn-sm">
                                    <i class="fa-regular fa-trash-can"></i>
                                <!-- sent data  -->
                                <form method="POST" class="d-inline">
                                  {% csrf_token %}
                                  <div class="d-none">
                                      <input type="text" name="email" id="email"  class="form-control w-50 form-row" value="{{i.useremail}}" required>
                                      <input type="text" name="password" id="password" class="form-control w-50 form-row mt-1" value="{{i.userpassword}}" required>
                                  <button type="submit" class="btn btn-danger btn-sm">
                                  <i class="fa-solid fa-envelope-circle-check"></i>
                        {% endif %}
                          {% endfor %}


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.IntegerField()
    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')
    useremail = models.CharField(max_length=100, blank=True, null=True)
    userpassword = models.CharField(max_length=100, blank=True, null=True)

    def __str__(self):
        return self.fullname

class EmailS(models.Model):
    ename = models.CharField(max_length=100, blank=True, null=True)
    epassword = models.CharField(max_length=200, blank=True, null=True)
    def __str__(self):
        return self.ename


def EAdmin(request):
    obj = EmailDb.objects.all().order_by('id')
    # paginator
    paginator = Paginator(obj, 4)
    page_number = request.GET.get('page')
    page_obj = paginator.get_page(page_number)
    total_page = page_obj.paginator.num_pages
    emaild = EmailDb.objects.all()

    # POST Request
    email = request.POST.get('email', '')
    password = request.POST.get('password', '')
    data = EmailS(ename=email, epassword=password)

    context = {'obj': page_obj, 'lastpage': total_page, 'totalPagelist': [n+1 for n in range(total_page)], 'em': emaild, 'email':email, 'password': password}
    return render(request, 'NEC/fdisplay.html', context)

You tell me - what happens when you do a GET on that page? (What code gets executed?)

user inserted data.
useremail = models.CharField(max_length=100, blank=True, null=True)
userpassword = models.CharField(max_length=100, blank=True, null=True)

Not on a GET. That’s what will happen if that page is accessed using POST.

let me know the code please.

Review the docs at Working with forms | Django documentation | Django to understand what all happens in a view and the difference between a GET and a POST.

you always suggest like this. this time please help me with code.

I always suggest to everyone that they review the relevent documentation first - and then come back with more specific questions when necessary. Becoming comfortable with reading and understanding technical documentation is an important skill that every developer should acquire.
I also understand that sometimes finding the right information in the docs may be difficult, and so I’m quite happy to point people in the direction of the information that may be of most use to them.