开发者

how to Reference some model in a db.ListProperty on google-app-engine

开发者 https://www.devze.com 2023-01-07 23:16 出处:网络
this is my model: class Geo(db.Model): entry = db.ListProperty(db.Key) geo=Geo() geo.entry.append(otherModel.key())

this is my model:

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

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

and the html is :

{% for i in geo.entry %}
        <p><a href="{{ i.link }}">{{ i开发者_如何学运维.title }}</a></p>
{% endfor%}

but it show nothing,

i think maybe should :

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

but it show :

ValueError: Item type Model is not acceptable

so , how to make the html shows the right thing.

thanks


You can't use that template (or the like) to show the model directly, but you can easily prepare a context with a list of models by simply calling db.get on the list of keys -- e.g., have {'entries': db.get(listofkeys), ... at the start of your context dictionary, and for i in entries in the template.

0

精彩评论

暂无评论...
验证码 换一张
取 消