Created
November 11, 2015 16:32
-
-
Save dhesson/e7def67f01d1de452920 to your computer and use it in GitHub Desktop.
Code fragment for a MongoEngine query result item to serializable JSON dictionary.
This file contains hidden or 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
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