如果两个结构化属性位于不同的模型中,我可以拥有两个同名的结构化属性吗?

Can I have two structured properties with the same name if they are in different Models?

根据 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)

您可以完美地做到这一点,但请注意,最好只定义一次规范模型,以免弄乱事情。但是...您还可以在每个文件上定义两个不同的规格模型。