假设我创建了几个pweewee
链接模型
db = SqliteDatabase('people.db')
class Person(Model):
name = CharField()
birthday = DateField()
class Meta:
database = db # This model uses the "people.db" database.
class Pet(Model):
owner = ForeignKeyField(Person, backref='pets')
name = CharField()
animal_type = CharField()
class Meta:
database = db # this model uses the "people.db" database
class Car(Model):
owner = ForeignKeyField(Person, backref='cars')
model = CharField()
class Meta:
database = db # this model uses the "people.db" database
如您所见,Car
和Pet
模型都连接到Person
. 假设我有一个可以是 acar
或 a的对象pet
。我不确定哪个,但我知道该owner
领域是一个外国领域。如何获取该字段的父模型?