[Answer]-Sending html to django template from view

1👍

Yes, it is usually best to do all HTML processing in the template. This way you can separate your database access logic from your display logic and thereby reduce coupling. It also means you can easily re use template.

So you should use the view function to get the appropriate objects and pass them to the template as variables.

Still, you are sort of on the right track. In order for your {{res}} variable to display properly I think you will need to change the template to.

<tbody>
    {% for message in res %}
    {{ message }}
    {% endfor %}
</tbody>

This should iterate over the elements in the res variable which you passed to the template.

Leave a comment