Helo. I am trying to list all the comments from one user and a topic that the comment belongs to, but i get double values in comment_list.html. I think i am not nesting it properly.
My Python hadler is following:
class CommentsListHandler(BaseHandler):
def get(self):
user = users.get_current_user()
comments = Comment.query(Comment.deleted==False, Comment.author_email==user.email()).fetch()
topics = Topic.query(Topic.deleted==False).fetch()
params = {"comments": comments, "topics": topics}
return self.render_template("comments_list.html", params=params)
My jinja2 is following:
{% for comment in comments|sort(attribute='created') %}
{% for topic in topics %}
<div class="panel panel-warning">
<div class="panel-heading">{{ comment.author_email }} on {{ comment.created.strftime("%d.%m.%Y at %H:%M") }}
in topic: <a href="/topic-details/{{topic.key.id()}}"> {{ topic.title }} </a></div>
<div class="panel-body">
<p>{{ comment.content }}</p>
</div>
</div>
{% endfor %}
{% endfor %}
I would realy appreciate your help. Thank you in advance.
Brg