Let's say I create several pweewee
link models
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
As you can see, both Car
and Pet
models are connected to a Person
. Let's say that I have an object which can be either
a car
or a pet
. I'm not sure whic, but I know that the owner
field is a foreign field. How can I get the parent model of that field?