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

前端 未结 4 1519
时光取名叫无心
时光取名叫无心 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:18

    toString converts it to the string and that can stored to session:

    session['_id'] = user['_id'].toString()
    

    alternative session['_id'] = str(user['_id'])

    The above fixed the error for me.

提交回复
热议问题