Created
December 22, 2020 16:00
-
-
Save sarojbelbase/ef9dacbf80321211d71be7730c85b042 to your computer and use it in GitHub Desktop.
flask dictionary without marshmallow
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import jsonify | |
@app.route('/user_json') | |
def get_json(): | |
user = User.query.filter_by(username='testme').first() | |
# Using the user object (without __dict__) will generate a runtime error | |
# TypeError: 'user' is not JSON serializable | |
return jsonify( user.__dict__ ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment