AttributeError:“Category”对象没有属性“serialize”

2024-10-04 07:29:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我得到了错误

TypeError:无法序列化JSON

@app.route('/catalog/json')
def catalogJSON():
    categories = session.query(Category).order_by(Category.name.asc())
    return jsonify(Category=[c for c in categories]) code here

然后我把线路改成

^{pr2}$

然后我得到AttributeError:“Category”对象没有属性“serialize”

我怎么能修好这个?谢谢。在


Tags: jsonapp序列化sessiondef错误orderquery