Flask Sqlite3 NOT NULL约束失败user.password

时间:2016-05-05 15:59:10

标签: python sqlite peewee

当我尝试将第一个用户添加到我的IntegrityError: NOT NULL constraint failed: user.password数据库中时,我收到了sqlite3。我不确定我使用user.password的位置导致此错误。手动将第一个用户添加到数据库后,我没有收到错误。有什么建议吗?

@classmethod
def create_user(cls, email, password, username, **kwards):
    email = email.lower()

    try:
        cls.select().where(
            (cls.email == email) | (cls.username == username)
        ).get()
    except cls.DoesNotExist:
            user = cls(username = username, email = email)
            user.password = user.set_password(password)
            user.save()
            return user
    else:
        raise Exception("User with that email exists already")

0 个答案:

没有答案