SQLAlchemy one to many relationship, how to filter the collection
问题 Bacially Product has a one to many relationship to ProductPicture . My product picture model looks like this: picture_type_enums = ('main', 'related', 'option') class ProductPicture(Base): __tablename__ = 'product_pictures' picture_id = Column(Integer, primary_key = True) product_id = Column(Integer, ForeignKey('products.product_id')) picture_type = Column(Enum(*picture_type_enums)) url = Column(String(120)) and my product model looks like this: class Product(Base): __tablename__ = 'products'