Reputation: 6296
Thanks to this post I changed my class to:
class Foo(db.Model):
name = db.StringProperty(multiline=True)
bars = db.ListProperty(db.Key)
class Bar(db.Model):
name = db.StringProperty(multiline=True)
Here a piece of my Django Template
<div >
<h3>{{ current_foo.name }}</h3>
{% for bar in current_foo.bars %}
<a href="/dialog_bar.html?id={{ bar.id }}" >{{ bar.name }}</a>
{% endfor %}
</div>
I don't manage to get the bars's name and the bars's id, How Can I do that?
What am I missing?
Upvotes: 0
Views: 72
Reputation: 599480
The best bet is to define a simple method or property on your Foo model that queries the database for the relevant Bars.
class Foo(db.Model):
...
def get_bars(self):
return db.get(self.bars)
Then you can call this in the template:
{% for bar in current_foo.get_bars %}
Upvotes: 1