Created
February 8, 2012 13:39
-
-
Save najeira/1769576 to your computer and use it in GitHub Desktop.
Get Key trough ReferenceProperty
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
from google.appengine.ext import db | |
class Foo(db.Model): | |
pass | |
class Bar(db.Model): | |
foo = db.ReferenceProperty(Foo) | |
Bar.foo.get_value_for_datastore(bar_obj) #=> Key of Foo |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Property.get_value_for_datastore メソッドは、データストアに保存する値を取得するメソッド。
ReferencePropertyはデータストアにはKeyを保存するので、これでKeyを取得できる。