flask-sqlalchemy orm 框架序列化
# 如果对象是ORM对象,则将其转换为字典并返回
if isinstance(obj.__class__, DeclarativeMeta):
return {c.name: getattr(obj, c.name) for c in obj.__table__.columns}
# 如果对象是ORM对象,则将其转换为字典并返回
if isinstance(obj.__class__, DeclarativeMeta):
return {c.name: getattr(obj, c.name) for c in obj.__table__.columns}