给定以下模型:
class Foo(db.model):
id = db.Column(db.Integer, primary_key=True)
bar_id = db.Column(
"bar_id",
db.Integer(),
db.ForeignKey("bar.id"))
baz_id = db.Column(
"baz_id",
db.Integer(),
db.ForeignKey("baz.id"))
bars = db.Relationship(
"Bar",
backref=backref("bar_foo", lazy="dynamic"))
bazs = db.relationship(
"Baz",
backref=backref("baz_foo", lazy="dynamic"))
class Bar(db.model):
id = db.Column(db.Integer, primary_key=True)
# some more columns
class Baz(db.model):
id = db.Column(db.Integer, primary_key=True)
# some more columns
q = Bar.query.get(123).bar_foo
# .all() gives me several Foo instances
我想为 q 结果检索不同的 Baz 实例