Сбой ограничения NOT NULL: posts_subscribe.firstname

Я пытаюсь получить данные из формы с помощью метода Post и сохранить их в базе данных. Однако, когда я нажимаю на кнопку submit, я продолжаю получать следующую ошибку:

NOT NULL constraint failed: posts_subscribe.firstname

Вот мой views.py

def subscribe(request):
    if request.method == 'POST':
        firstname=request.POST.get('firstname')
        secondname=request.POST.get('secondname')
        email=request.POST.get('email')
        phonenumber=request.POST.get('phonenumber')
        en= Subscribe(firstname=firstname, secondname=secondname, email = email, phonenumber = phonenumber)
        en.save()

        return redirect('/')
        
    return render(request, 'subscribe.html')

Мой models.py

class Subscribe(models.Model):
    firstname = models.CharField(max_length=30, blank = True)
    secondname = models.CharField(max_length=30, blank = True)
    email = models.CharField(max_length=30)
    phonenumber = models.IntegerField()

Вот мой шаблон

{% extends 'index.html' %}
{% block subscribe %}
<div class="card mx-5">
    <h1 class="mx-5 mt-3"> Subscribe</h1>
    <form method="POST" enctype="multipart/form-data" action="subscribe">
        {% csrf_token %}
        <div class="mb-3 mx-5">
            <label for="firstname" class="form-label ">First Name</label>
            <input type="text" class="form-control form-control-lg" id="firstname" placeholder="firstname">
        </div>
        <div class="mb-3 mx-5">
            <label for="secondname" class="form-label">Second Name (Optional)</label>
            <input type="text" class="form-control form-control-lg" id="secondname" placeholder="secondname">
        </div>
        <div class="mb-3 mx-5">
            <label for="email" class="form-label">Email</label>
            <input type="email" class="form-control form-control-lg" id="email" placeholder="example@example.com">
        </div>
        <div class="mb-3 mx-5">
            <label for="phonenumber" class="form-label">Phonenumber</label>
            <input type="number" class="form-control form-control-lg" id="phonenumber" placeholder="0712345678">
        </div>
        <div class="mb-3 mx-5">
            <button type="submit" class="btn-primary"> Subscribe</button>
        </div>     
    </form>
</div>
{% endblock %}

И мои шаблоны url


urlpatterns= [
    path('', views.index, name='index'),
     
    path('subscribe', views.subscribe, name ='subscribe'),
    path('allposts', views.allposts, name='allposts'),
    path('political', views.political, name='political'),
    path('religion', views.religion, name='religion'),
    path('trending', views.trending, name='treniding'),
   
    path('<str:pk>', views.post, name='post'),
 
   
]

Любая помощь будет очень признательна

Вы должны добавить name="…" атрибут [mdn] к <input> элементам, так:

<input type="text" name="firstname" class="form-control form-control-lg" id="firstname" placeholder="firstname">
…
<input type="text" name="secondname" class="form-control form-control-lg" id="secondname" placeholder="secondname">
…
<input type="email" name="email" class="form-control form-control-lg" id="email" placeholder="example@example.com">
…
<input type="number" name="phonenumber" class="form-control form-control-lg" id="phonenumber" placeholder="0712345678">
Вернуться на верх