Getting 'TypeError: ObjectId('') is not JSON serializable' when using Flask 0.10.1

前端 未结 4 1511
时光取名叫无心
时光取名叫无心 2021-02-03 10:43

I forked the Flask example, Minitwit, to work with MongoDB and it was working fine on Flask 0.9, but after upgrading to 0.10.1 I get the error in title when I login when I try t

4条回答
  •  一向
    一向 (楼主)
    2021-02-03 11:08

    This is how I've recently fixed the error

    @app.route('/')
    def home():
        docs = []
        for doc in db.person.find():
            doc.pop('_id') 
            docs.append(doc)
        return jsonify(docs)
    

提交回复
热议问题