为了获取实体的字符串编码键,我只需执行以下操作:
key = entity.key()
string_encoded_key = str(key)
我通过 ReferenceProperty 引用了另一个实体。
class ParentClass(db.Model):
name = db.StringProperty()
class ChildClass(db.Model):
name = db.StringProperty()
bio_parent = db.ReferenceProperty(ParentClass)
johnnys_parent = ParentClass(name="John").put()
child = ChildClass(name="Johnny",bio_parent=johnnys_parent).put()
#getting the string-encoded key of the parent through the child
child = ChildClass.all().filter("name","Johnny").get()
string_encoded_key = str(child.bio_parent) # <--- this doesn't give me the string-encoded key
如何在不获取父实体的情况下通过子实体获取生物父的字符串编码键?
谢谢!