我正在使用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