Skip to content

Instantly share code, notes, and snippets.

@dhesson
Created November 11, 2015 16:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save dhesson/e7def67f01d1de452920 to your computer and use it in GitHub Desktop.
Save dhesson/e7def67f01d1de452920 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