我正在使用Flask和Peewee为Users
和Appointments
创建模型,并且它们中的每个模型都有一个引用对方的ForeignKeyField
。问题是,如果我定义一个在另一个之上,Flask将给我x is not defined
。模型未定义
例如:
class User(Model):
appointments = ForeignKeyField(Appointment, related_name='appointments')
class Appointment(Model):
with_doctor = ForeignKeyField(User, related_name='doctor')
这将返回'User' is not defined
。我怎样才能解决这个问题?
如果我这样做,我得到TypeError:issubclass()arg 1必须是一个类。 – josh