根據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'來代替事物來清除/簡單化:) –