谷歌应用程序引擎:我怎样才能有一个对象的列表作为另一个类中的属性? [英] google-app-engine: How can I have a list of objects as property in another class?
本文介绍了谷歌应用程序引擎:我怎样才能有一个对象的列表作为另一个类中的属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何在 google appengine db model
from google.appengine.ext import db
Class Car(db.Model):
name=db.StringProperty()
model=db.StringProperty()
mileage=db.IntegerProperty()
Class Person(db.Model):
name=db.StringProperty()
age=db.IntegerProperty()
cars=db.ListProperty(Car) # How can I have cars object for person containing list of Car Objects?
谢谢
Thank you
推荐答案
查看参考文档 http://code.google .com / appengine / docs / python / datastore / datamodeling.html#参考资料
它的运作方式相反,Class Car会有
It works the other way round, class Car would have
person = db.ReferenceProperty(Person, collection_name="cars")
这可以让一辆汽车在Person中使用。
which would make a property cars available in Person.
希望这有助于您。
这篇关于谷歌应用程序引擎:我怎样才能有一个对象的列表作为另一个类中的属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文