S
S
sazhyk2016-12-27 16:22:41
Django
sazhyk, 2016-12-27 16:22:41

How to display a list of records from a table, sorted by id?

I don't know how to better phrase the question. There are records of people - persons . Received simply
'persons': Person.objects.all(),
In the template, everything is displayed in a cycle

{% for person in persons %}
    {{ person  }}
{% endfor %}

Actually the question is that they are displayed by date of update, the most recent at the bottom. But I need them to be displayed by id , from largest to smallest. I can't figure out where this is being done. Tell me please. If you need to bring some other piece of code, from a view, or a model, or a template, then I will.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question