Rendering database information
We have already built a form that sends a new message to the backend via a WebSockets connection, which we capture in the consumer and then store in the database.
Now we’re going to get all the messages from the database, render them with Django’s template engine, send the HTML to the client over the connection we kept, and inject the content into the appropriate frontend element.
Create the HTML template that will generate all the message blocks in the path /app/website/templates/components/_list-messages.html
with the content:
{% for message in messages %} <article class="message" id="message--{{ message.id }}"> <h2 class="message__author">{{ message.author }} </h2> ...