У меня проблема с базой данных Django. в модели

Я указал, что поля биографии и изображения могут быть пустыми, но почему он выдает ошибку и говорит, что я должен их заполнить? enter image description here

class User_account(models.Model):
    email = models.EmailField()
    fullname = models.CharField(max_length=30)
    username = models.CharField(max_length=20)
    password = models.CharField(max_length=30)
    marital_status = models.BooleanField(default=False)
    bio = models.CharField(null=True, max_length=200)
    visitor = models.IntegerField(default=0)
    image = models.ImageField(null=True, upload_to='profile_img')

Specifying null=True [Django-doc] does not mean the field is not required. null=True has only impact on the database: it makes the field NULLable. You should use blank=True [Django-doc] to make the field not required:

class User_account(models.Model):
    # …
    bio = models.CharField(null=True, blank=True, max_length=200)
    # …
    image = models.ImageField(null=True, blank=True, 

Примечание: Модели в Django пишутся в PascalCase, а не snake_case, поэтому вы можете переименовать модель из User_account в UserAccount.

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