【问题标题】:Equivalent replacement for ListProperty(db.Key) in djangoappenginedjangoappengine 中 ListProperty(db.Key) 的等效替换
【发布时间】:2010-07-28 11:46:26
【问题描述】:

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

ListProperty(db.Key) 

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

【问题讨论】:

  • 这是正确的方法吗:citys = ListField(models.ForeignKey(City))

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


【解决方案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

【讨论】:

    猜你喜欢
    • 2012-08-22
    • 2016-12-09
    • 2017-07-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-07
    • 2010-10-17
    相关资源
    最近更新 更多