【发布时间】:2014-02-06 14:40:06
【问题描述】:
我有一个实体,其中包含可变数量的另一个实体(所以我使用结构化属性,重复 = True),但一个属性也可以包含可变数量的单个实体类型。所以我的代码如下所示:
class Property(ndb.Model):
name = ndb.StringProperty()
cost = ndb.FloatProperty()
type = ndb.StringProperty()
class SpecialProperty(ndb.Model):
name = ndb.StringProperty()
properties = ndb.StructuredProperty(Property, repeated=True)
type = ndb.StringProperty()
class Hotel(ndb.Model):
specialProperties = ndb.StructuredProperty(SpecialProperty, repeated=True)
但是当我尝试这个 GAE 时会抛出一个错误。 “TypeError:此 StructuredProperty 不能使用重复=True,因为它的模型类 (SpecialProperty) 包含重复的属性(直接或间接)。”
那么我该如何绕过呢? 我真的需要这种灵活的结构。
非常感谢。
【问题讨论】:
标签: python google-app-engine google-cloud-datastore