python - Fetching just the Key/id from a ReferenceProperty in App Engine -
I can use a little help in AppEngine Land ...
[Python] API I Using Relationships Make Relationships Like This Example:
Class Authors (DB Model): name = db.StringProperty () Category Story (db.Model): author = db.ReferenceProperty (Author) story = db.get (story_key) author_name = story.author.name
As I understand, that example will give two datastore questions. To bring a story to one and then use a name to honor the writer within. But I want to be able to bring the ID, so do something like this:
story = db.jet (story_key) author_id = story.author.key (). Id ()
I want to get the ID from the bus reference
By reading the document it says that
The value of reference portfolios is important
Who leads me to think that I can just call .id () at the value of the reference. But also says:
Reference property model provides features for main property values such as automatic deployment.
Can not find anything told to me when is it referred?
Is it safe? Reference property on id ()?
Can it be assumed that calling .id () will not be the cause of a datastore lookup?
Answer your question to help fellow searchers ...
In the form of suspicious calling story Author. (). ID () or even the story .. Author. () Will result in test questions. The correct method is:
story = db.get (story_key) author_id = Story.author.get_value_for_datastore (story) .id ()
Comments
Post a Comment