Forum.post_count = column_property(select([func.count()], Message.__table__
    .c.forum == Forum.__table__.c.id).correlate(Forum.__table__).as_scalar(
    ).label('post_count'), deferred=True)
How to return the count of related entities in sqlalchemy query