[英]ndb python appengine odd behavior models referencing each other
在使用KeyProperty引用模型时,似乎必须在引用模型之前对其进行初始化。我是否在这里错过了一些信息?
from google.appengine.ext import ndb
#initialize here
class Vessel(ndb.Model):
pass
class Manifest(ndb.Model):
vessellist = ndb.KeyProperty(Vessel)
class Vessel(ndb.Model):
manifest = ndb.KeyProperty(Manifest)
这是正常现象。 如果要避免按特定顺序放置模型,并且希望使用类似的交叉引用,则可以使用字符串而不是模型类来引用模型:
class Manifest(ndb.Model):
vessellist = ndb.KeyProperty('Vessel')
class Vessel(ndb.Model):
manifest = ndb.KeyProperty('Manifest')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.