当我尝试将第一个用户添加到我的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")