I
I
Ilya2016-10-27 09:44:43
Django
Ilya, 2016-10-27 09:44:43

How to display dictionaries in a template?

How to display nested dictionaries in a template?
Vocabulary:

users = {0: {'likes': 1, 'first_name': 'Алена', 'id': 92812055, 'hidden': 1}}

Tried to output like this:
{% for items in users %}
  {{ items.last_name }}
    {{ items.likes }} лайков
{% endfor %}

did not work.
UPD:
Tell me how to sort by 'likes' value.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ilya, 2016-10-27
@nuBacuk

Solved the problem with output:

{% for items in users.items %}
  {{ items.last_name }}
    {{ items.likes }} лайков
{% endfor %}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question