Python sqlite3.IntegrityError:非空约束失败

Python sqlite3.IntegrityError:非空约束失败,python,django,sqlite,Python,Django,Sqlite,在这是我第一次使用youtube之前,我从未处理过文件上传,我遵循了youtube上的说明。显然,当我在模型中添加一个文件字段并尝试迁移时,它抛出了一些异常,我不知道如何修复它。我试图删除参数,但它仍然给我一个错误。请帮助我(我使用django btw) 型号.py class Profile(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE) email = models.Text

在这是我第一次使用youtube之前,我从未处理过文件上传,我遵循了youtube上的说明。显然,当我在模型中添加一个文件字段并尝试迁移时,它抛出了一些异常,我不知道如何修复它。我试图删除参数,但它仍然给我一个错误。请帮助我(我使用django btw)

型号.py

class Profile(models.Model):
    user = models.OneToOneField(User, on_delete=models.CASCADE)
    email = models.TextField(max_length=500, blank=True)
    contact_number = models.CharField(max_length=30, blank=True)
    profile_photo = models.FileField(null=True,blank=True)

@receiver(post_save, sender=User)
def create_user_profile(sender, instance, created, **kwargs):
    if created:
        Profile.objects.create(user=instance)

@receiver(post_save, sender=User)
def save_user_profile(sender, instance, **kwargs):
    instance.profile.save()
然后这个错误出现了,我无法理解

Running migrations:
  Applying bartr.0011_profile_profile_photo...Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/django/db/backends/sqlite3/base.py", line 337, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.IntegrityError: NOT NULL constraint failed: bartr_profile.profile_photo

执行
.schema TABLENAME
,其中TABLENAME是sqllite中的表名,并检查profile\u photo column约束是否默认设置为NOT NULL。@Keerthana您好,很抱歉我没有完全理解您的意思。我现在的理解是我强迫我的个人资料照片接受空值。现在我有一个问题,当我试图把一个值,它给我的完整性错误。你能再解释一下吗?我也不知道在哪里执行,我用的是pycharm