Reader small image

You're reading from  Building SPAs with Django and HTML Over the Wire

Product typeBook
Published inAug 2022
PublisherPackt
ISBN-139781803240190
Edition1st Edition
Tools
Right arrow
Author (1)
Andros Fenollosa
Andros Fenollosa
author image
Andros Fenollosa

Andros Fenollosa is a custom programming expert that works as a teacher, full stack developer, and mobile developer. He's a Web Designer, Web Programmer, and Apps Programmer, among other things ( PWA, Android and iOS ). He has a plethora of commercial expertise, having worked on projects in a variety of locales throughout the world.
Read more about Andros Fenollosa

Right arrow

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...

lock icon
The rest of the page is locked
Previous PageNext Page
You have been reading a chapter from
Building SPAs with Django and HTML Over the Wire
Published in: Aug 2022Publisher: PacktISBN-13: 9781803240190

Author (1)

author image
Andros Fenollosa

Andros Fenollosa is a custom programming expert that works as a teacher, full stack developer, and mobile developer. He's a Web Designer, Web Programmer, and Apps Programmer, among other things ( PWA, Android and iOS ). He has a plethora of commercial expertise, having worked on projects in a variety of locales throughout the world.
Read more about Andros Fenollosa