Fetching just the Key/id from a ReferenceProperty in App Engine

北城余情 提交于 2019-12-02 19:18:30

Answering my own question for the sake of helping fellow searchers...

As suspected calling story.author.key().id() or even story.author.id() will result in datastore queries. The correct method dictated by the API docs is:

story = db.get(story_key)
author_id = Story.author.get_value_for_datastore(story).id()
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!