AppEngineに問題があり、理解できないようです。
from google.appengine.ext import ndb
from google.appengine.ext.ndb import polymodel
class Item(polymodel.PolyModel):
name = ndb.StringProperty()
type = ndb.StringProperty(choices=["Medical","Food"])
sub_category_type = ndb.StringProperty()
sub_category_sub_type = ndb.StringProperty()
class MedicalItem(Item):
med_sub_type = ndb.StringProperty()
can_split_item = ndb.BooleanProperty()
class ItemInHouse(ndb.Model):
item = ndb.StructuredProperty(Item)
amount_of_item = ndb.FloatProperty()
したがって、上記のクラスを使用して、すべてのItemInHouseを照会し、MedicalItemを持つそれらのiteminhouseにアクセスしようとすると、med_sub_typeを取得できません。あれは:
itms = ItemInHouse.query(ItemInHouse.item.type == "Medical").fetch()
for itm in itms:
self.response.out.write(itm.item.med_sub_type)
itm.item.med_sub_typeでエラーをスローします。私も試しました:itm.item._values["med_sub_type"].b_val
しかし、これでもAttributeErrorがスローされます:'Item'オブジェクトには属性'med_sub_type'がありません。私はclass_
それが持っているプロパティItem
とプロパティを確認しMedicalItem
ますが、アクセスできません。何か案は?
ありがとうジョン