djangoappengine中ListProperty(db.Key)的等效替换

时间:2010-07-28 11:46:26

标签: django google-app-engine django-models django-nonrel djangoappengine

我尝试使用djangoappengine,但我不确定如何编写模型以合并标准

ListProperty(db.Key) 

我知道djangotoolbox提供了这种字段类型,但我无法弄清楚确切的语法。

1 个答案:

答案 0 :(得分:1)

db.ListProperty(db.Key)存储任何实体密钥的列表。

模型:

class Profile(db.Model):
data_list=db.ListProperty(db.Key)

class Data(db.Model):
name=db.StringProperty()

的观点:

prof=Profile()
data=Data.all()

for data in data:
    prof.data_list.append(data)

/// Here data_list stores the keys of Data entity

Data.get(prof.data_list) will get all the Data entities whose key are in the data_list attribute
相关问题