2010-07-17 13 views
0

這是我的模型:如何引用一些模型,對谷歌 - 應用程序 - 發動機db.ListProperty

class Geo(db.Model): 
    entry = db.ListProperty(db.Key) 

geo=Geo() 
geo.entry.append(otherModel.key()) 

和HTML是:

{% for i in geo.entry %} 
     <p><a href="{{ i.link }}">{{ i.title }}</a></p> 
{% endfor%} 

,但它什麼都不顯示,

我想,也許應該:

class Geo(db.Model): 
    entry = db.ListProperty(db.Model) 
geo=Geo() 
geo.entry.append(otherModel) 

但它顯示:

ValueError: Item type Model is not acceptable 

所以,如何使html顯示正確的東西。

感謝

回答

1

不能使用該模板(或類似)直接顯示模式,但你可以很容易地通過簡單地調用鍵的名單上db.get準備與型號列表中的情況下 - 例如,{'entries': db.get(listofkeys), ...位於上下文字典的開頭,for i in entries位於模板中。

相關問題