obtain collection_name from parent's key in GA

2019-08-20 06:56发布

is it possible to ask parent for its refered collection_name based on one of its keys, lets say i have a parent db model and its key, can i know ths children who refer to this parent through collection name or otherwise

class Parent(db.Model):
  user = db.UserProperty()

class Childs(db.Model):
  refer = db.ReferenceProperty(Parent,collection_name='children')

2条回答
手持菜刀,她持情操
3楼-- · 2019-08-20 07:25

I think you're asking "can I get the set of all the children that refer to a given parent".

In which case, yes you can, it's a property of the Parent class.

Assuming you have a Parent object p then the children that reference it will be in p.children

If you hadn't specified the collection_name on the ReferenceProperty they would be in p.childs_set

Check out the documentation.

查看更多
登录 后发表回答