Skip to content

Instantly share code, notes, and snippets.

@chan-lee
Last active August 29, 2015 14:01
Show Gist options
  • Save chan-lee/e436c8e5dec893bbf1d9 to your computer and use it in GitHub Desktop.
Save chan-lee/e436c8e5dec893bbf1d9 to your computer and use it in GitHub Desktop.
class RestModel(ndb.Model):
def to_dict(self, **kwargs):
result = super(RestModel, self).to_dict(**kwargs)
result['id'] = self.key.id()
parent_key = self.key.parent()
if parent_key is not None:
result['parent'] = parent_key.id()
return result
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment