Template not showing Values

I have this simple view which sends the comments in the context.

def room(request,pk):
    room = Room.objects.get(id=pk)
    messages = room.message_set.all()
    description = room.description.split('\n')
    context = {'room':room, 'description':description,messages:'messages'}
    return render(request, 'base/room.html', context)

The corresponding HTML and DTL is as below

{% extends 'main.html' %}
{% block content %}
<h1>{{room.name}}</h1>
<p>{{room.description}}</p>
<div class="comment-wrapper">
    <h3>Conversation</h3>
    <hr> 
    {% for message in messages %}
        <div>
            <small>
                @{{messages.user}} - {{messages.created}}         
            </small>
        </div>
    {% endfor %}
</div>
{% endblock %}

However I dont see the messages in the rendered HTML. What am I missing.

When posting code, templates, html, or error messages here, enclose the code between lines of three backtick - ` characters. This means you’ll have a line of ```, then your code, then another line of ```. This forces the forum software to keep your code properly formatted. (I’ve taken the liberty of editing your original post. Please remember to do this in the future.)

1 Like

Your definition in your context is incorrect:

Thanks Ken! That was the issue!