【发布时间】:2011-10-03 07:42:41
【问题描述】:
所以我有两个模型类:
class Dog(db.model):
dogName = StringProperty()
dogBreed = StringProperty()
class Cat(db.model):
catName = StringProperty()
catBreed = StringProperty()
然后我有第三个模型类来保存所有图片
class Images(db.model):
imageReference = ReferenceProperty(*Animal*, collection_name = 'allImages')
imageURL = StringProperty()
动物要么是狗,要么是猫。显然这不会编译。
现在我的问题是:有没有办法可以将猫的照片和狗的照片放在一起?还是我需要创建更多这样的模型:
class DogImages(db.model):
imageReference = ReferenceProperty(Dog, collection_name = 'allImages')
imageURL = StringProperty()
class CatImages(db.model):
imageReference = ReferenceProperty(Cat, collection_name = 'allImages')
imageURL = StringProperty()
【问题讨论】:
标签: google-app-engine data-modeling google-cloud-datastore