Place.query.filter(Place.is_deleted == False)
class CustomQuery(Query):
def __new__(cls, *args, **kwargs):
if args and hasattr(args[0][0], "is_deleted"):
return Query(*args, **kwargs).filter_by(is_deleted=False)
else:
return object.__new__(cls)
session = scoped_session(sessionmaker(query_cls=CustomQuery))
Источник.CREATE VIEW actual_places AS
SELECT *
FROM places
WHERE is_deleted = FALSE;