【发布时间】:2016-12-29 00:07:28
【问题描述】:
根据 Google NDB 文档,Model() 种类被认为是一个全局命名空间,所以我不应该有两个同名的 ndb 模型,即使在不同的文件中也是如此。尽管如此,结构化属性不是成熟的实体,它们没有密钥,如果我在控制台中搜索它们,它们不存在,而是其他实体的属性。考虑到这一点,我可以有类似下面的代码吗?
这在 file_A.py 中:
class Specifications(ndb.Model):
#A list of Specifications
class Car(ndb.Model):
specs = ndb.StructuredProperty(Specifications)
这在file_B.py中:
class Specifications(ndb.Model):
#Another list of Specifications
class Bike(ndb.Model):
specs = ndb.StructuredProperty(Specifications)
【问题讨论】:
-
我会使用
CarSpecs和BikeSpecs来保持事情的清晰/简单 :)
标签: python google-app-engine google-cloud-datastore app-engine-ndb