Filtering After A Join In Flask-sqlalchemy
I have two tables( location and country ) that am trying to query; which are represented by the models below in my flask application from sqlalchemy import Column, DateTime, Foreig
Solution 1:
filter_by()
applies to the primary entity of the query, or the last entity that was the target of a join()
. In your case that is Country
, which does not have the required attribute. Either use filter()
or move the call to filter_by(location_name=...)
before the join:
Location.query.\
filter_by(location_name='Cairo').\
join(Country).\
filter_by(country_id=67).\
first()
Post a Comment for "Filtering After A Join In Flask-sqlalchemy"