Adding a list of comments
The blog is functional: we can list articles, navigate between pages, paginate, and perform a search. But an essential element is still missing: comments. That’s why we are going to print all the comments that belong to an article.
We start by creating a template that lists all the comments. We add a new component in app/website/templates/components/_list_of_comments.html
with the following content:
{% for comment in comments %} {% include "components/_single_comment.html" with comment=comment %} {% endfor %}
This, in turn, will need the app/website/templates/components/_single_comment.html
component:
<article> <h2>{{ comment.author }}</h2> <p>{{ comment.content }}</p> <p>{{ comment.created_at }}</p> </article>
In the views (app/website/views...