Skip to content

Instantly share code, notes, and snippets.

@pavan538
Forked from dhesson/somegist.py
Created December 16, 2018 13:31
Show Gist options
  • Save pavan538/bbf764063cf36fc4ca67755cee278328 to your computer and use it in GitHub Desktop.
Save pavan538/bbf764063cf36fc4ca67755cee278328 to your computer and use it in GitHub Desktop.
Code fragment for a MongoEngine query result item to serializable JSON dictionary.
data = o.to_mongo()
o_id = data.pop('_id', None)
if o_id:
data['id'] = str(o_id)
data.pop('_cls', None)
return data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment