0

I am currently learning Python & Flask. As you know with Flask SQLAlchemy we use the query.all() statement to get all data from our model. For example, defining a GET endpoint to get all users from our User model would require jsonifying the result of User.query.all(). How ever this statement "return jsonify(User.query.all())" returns the error of "TypeError: Object of type 'User' is not JSON serializable".

What is the easiest way or the best practice for jsonifying query.all() result in your GET statement that would list all users in your model?

Thanks.

Can
  • 1
  • 1
  • Does this answer your question? [How to serialize SqlAlchemy result to JSON?](https://stackoverflow.com/questions/5022066/how-to-serialize-sqlalchemy-result-to-json) – Patrick Yoder Jan 31 '22 at 15:46
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. – Community Feb 10 '22 at 06:00

0 Answers0