A
A
Alexander Leyba2019-08-14 16:05:45
Django
Alexander Leyba, 2019-08-14 16:05:45

How to get all records except the last one?

Good afternoon, I need to display 3 latest news on the main page, but one of them is the newest one and is enlarged and highlighted, therefore it is necessary to display the last 2 next to it besides it.
At the moment I have this, but it is not correct.

last_three = News.objects.order_by('-id')[0:3]
one_news = News.objects.all().last()

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