Данные не забиваются в базу данных из формы Django

После написания всех данных в формах ничего не добавляется в бд, хотя в терминале пишет, что пост запрос отправлен и не выдает ошибок. Как исправить?

forms.py

from django.forms import ModelForm, TextInput, Textarea, NumberInput, FileInput
from .models import Recipe

class FoodForm(ModelForm):
    class Meta:
        model = Recipe
        fields = ["recipe_title", "recipe", "recipe_time", "recipe_ingridients", "author_name", "image"]
        widgets = {
            "recipe_title" : TextInput(
                attrs={
                    "class" : "title_form",
                    "placeholder" : "Введите название рецепта"
                }
            ),
            "recipe": Textarea(
                attrs={
                    "class": "form_of_all",
                    "placeholder": "Введите ваш рецепт"
                }
            ),
            "recipe_time" : NumberInput(
                attrs={
                    "class" : "ingr",
                    "placeholder" : "Введите время"
                }
            ),
            "recipe_ingridients": NumberInput(
                attrs={
                    "class": "ingr",
                    "placeholder": "Введите кол-во ингридиентов"
                }
            ),
            "image" : FileInput(
                attrs={
                    "name" : "input__file",
                    "id" : "input__file"
                }
            )

        }

models.py

from django.db import models


class Recipe(models.Model):
    recipe_title = models.CharField(max_length=20)
    recipe_time = models.IntegerField(max_length=3)
    recipe_ingridients = models.IntegerField(max_length=2)
    author_name = models.CharField(max_length=30)
    image = models.ImageField(upload_to='')
    recipe = models.TextField(max_length=300)

views.py

def crate(requset):
    form = FoodForm()
    if requset.method == "POST":
        form = FoodForm(requset.POST)
        if form.is_valid():
            form.save()


    context = {
        "form" : form
    }

    return render(requset, "food/crate.html", context)

html

{% extends 'food/crate_base.html' %}
{% load static %}


{% block content %}
    <div class = "body_of_content">
             <span class = "text_">Создать Рецепт</span>
             <div class = "back1"><img src = "{% static 'images_defolt/back1.png' %}" class = "first_img"></div>
             <div class = "back2"><img src = "{% static 'images_defolt/back1.png' %}" class = "first_img"></div>
            <form method="post">
                {% csrf_token %}
                {{ form.recipe_title }}<br>
                {{ form.recipe }}<br>
                {{ form.recipe_time }}<br>
                {{ form.recipe_ingridients}}<br>


                 <label for="input__file" class="input__file-button">
                    {{ form.image }}<br>
                  <span class="input__file-icon-wrapper"><img class="input__file-icon" src="{% static 'images_defolt/down.png' %}" alt="Выбрать файл" width="25"></span>
                  <span class="input__file-button-text">Выберите файл</span>
               </label>
                 <button class = "create_btn" type = "submit" formmethod="post" >Создать</button>
            </form>


         </div>
{% endblock %}

Возможно, ошибка в том, что вы не даете заполнить данные для author_name, которые обязаны быть заполнены. Думаю, для его модели стоит прописать

author_name = models.CharField(max_length=30, null=True, blank=True)

чтобы не было обходимости его заполнять

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