S
S
Sergey Nizhny Novgorod2016-02-18 07:05:12
Django
Sergey Nizhny Novgorod, 2016-02-18 07:05:12

How to set the output order of objects.all() in django?

There is a view:
stepitems = Step.objects.all()
It displays 10 articles in order from the Step model. When creating articles, I typed them in order, so there was no problem with the correctness of the output. However, after I made a couple of changes to the articles, the whole output order went wrong and the articles began to be displayed in the wrong order. At the same time, all articles have a sequential ID, which for some reason is ignored.
It feels like these numbers got lost. But they cannot be corrected.
download?id=i1u9qZripRvw79ubMmo57qVa062Y
Is there a way to somehow sort the output by article id?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
O
Oscar Django, 2016-02-18
@Terras

stepitems = Step.objects.all().order_by('id')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question