1. 程式人生 > >Sqlalchemy多對一查詢AttributeError: Neither 'InstrumentedAttribute' object nor 'Comparator' object...

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)