Juan Juan - 1 month ago 7
Python Question

Accessing ReferenceProperty values in a one to many relation from a referenced key in Appengine?

I am using AppEngine in Python and I have two Models using ndb :

# Post model
class WikiPost(ndb.Model) :
url = ndb.StringProperty(required = True)
content = ndb.TextProperty(required = True)
date = ndb.DateProperty(auto_now_add = True)

Second Model

class WikiPostVersion(ndb.Model) :
r_post = ndb.KeyProperty(kind = WikiPost)
content = ndb.StringProperty()
date = ndb.DateProperty(auto_now_add = True)

How I can Access the values of the referenced key r_post of the model WikiPostVersion?


r_post is a key, so you can just call .get() on it.

referenced_wikipost = my_wikipostversion_instance.r_post.get()