Skip to content

Instantly share code, notes, and snippets.

@najeira
Created February 8, 2012 13:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save najeira/1769576 to your computer and use it in GitHub Desktop.
Save najeira/1769576 to your computer and use it in GitHub Desktop.
Get Key trough ReferenceProperty
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
@najeira
Copy link
Author

najeira commented Feb 8, 2012

Property.get_value_for_datastore メソッドは、データストアに保存する値を取得するメソッド。
ReferencePropertyはデータストアにはKeyを保存するので、これでKeyを取得できる。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment