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

后端 未结 1 1296
挽巷
挽巷 2021-02-01 22:11

I could use a little help in AppEngine land...

Using the [Python] API I create relationships like this example from the docs:

class Author(db.Model):
           


        
相关标签:
1条回答
  • 2021-02-01 22:59

    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()
    
    0 讨论(0)
提交回复
热议问题