P
P
progerstas2021-04-17 22:37:48
Flask
progerstas, 2021-04-17 22:37:48

Why is the text not showing?

html:

<div class="chats">
            <div class="messages">
                {% for chat in chats %}
                <div class="chat_name"> {{chat.first_name}} {{chat.last_name}} </div>
                {% endfor %}
            </div>
        </div>


python in function:
print(chats)
return render_template("index.html", chats = chats)


chats:


But if you print chat instead of chat.first_name then everything works

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alegzz, 2021-04-17
@progerstas

change chat.first_name to chat.0.first_name. by analogy, change the rest in the same way

A
alexbprofit, 2021-04-17
@alexbprofit

not chat.first_name but chat["first_name"]

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question