您将如何在两个不同的实体模型之间建立关系?
当我尝试这个时,我收到一个错误:
class Spec(ndb.Model):
userKey = ndb.KeyProperty(kind=User)
class User(ndb.Model):
specs = ndb.KeyProperty(kind=Spec, repeated=True)
我理解的错误源于在定义之前引用User。 我做了以下解决方案,我使用了get_by_id,但我不喜欢这个解决方案:
class Spec(ndb.Model):
userKey = ndb.IntegerProperty()
class User(ndb.Model):
specs = ndb.KeyProperty(kind=Spec, repeated=True)
你如何解决这个问题,以便我可以像第一个例子中那样定义我的模型?更好的是,你将如何在自己的文件/模块中定义每个类。
我尝试过这篇文章,但似乎已经过时且与ndb无关。 https://developers.google.com/appengine/articles/modeling
谢谢