Sqlalchemy多对一查询AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object...

Children.query.filter(Children.parent.id==1)

报错:
AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object associated with Children.parent has an attribute 'id'

改为:
Children.query.join(Parent).filter(Parent.id==1)

猜你喜欢

转载自blog.csdn.net/qq_37998074/article/details/84581600