I have method like this , and want to return as Json , but it writes that Posts object is not Json serializable :S
def show_results_async(text):
query = { '$or':[{'title':{'$regex':text}},{'author':{'$regex':text}} ]}
posts = Posts.objects(__raw__=(query))
return jsonify(result = posts)
tl,dr: There is no built-in function that’ll convert a MongoEngine document to JSON. So you’ll need to write your own.
In views.py:
In post.py, add:
In helper.py:
A couple of notes: