【发布时间】:2016-09-09 03:01:50
【问题描述】:
我有以下型号并收到IntegrityError: NOT NULL constraint failed: terms.sets_id 错误。我检查了其他帖子,唯一能找到的应该是我没有传入所有参数,但我声明了五个字段,并将 5 个值传入concept = cls(...)。我错过了什么?
class Terms(UserMixin, BaseModel):
term_id = CharField()
sets_id = CharField()
term_count = IntegerField()
term = TextField()
definition = TextField()
@classmethod
def include_term(cls, set_id, term_id, definition, rank, term, **kwards):
try:
cls.select().where(cls.term_id == term_id).get()
except cls.DoesNotExist:
print("putting term into db")
concept = cls(
set_id = set_id,
term_id = term_id,
term= term,
definition = definition,
rank = rank )
concept.save()
print(concept.term)
print("term saved to db")
return concept
else:
raise Exception("Term with that id already exists")
【问题讨论】:
标签: python peewee flask-peewee