I\'m using Flask, SQLAlchemy and javascript. I need to pass the results of my query to javascript in the json format, through AJAX, but I keep getting this error:
Like the error message says, you cannot call jsonify
on a SQLAlchemy model object (I don't think you can pickle them either). Try:
clouds_d[idx] = dict((k, cloud.__dict__[k]) for k in cloud.__dict__ if k[0] != '_')
or better yet, be explicit:
clouds_d[idx] = {
'id': cloud.id,
'other_attrs': '...',
}