I am saving EmailDb filed 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.

fdisply.html reference image

{% 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
Back to Top