Reputation: 9595
As the title explains, lets say I have the following queries:
main_article = Article.objects.latest()
prev_articles = Article.objects.all().order_by('-created')
I want the prev_articles
to not include the latest article (the object that is main_article
). I tried looking this up, but can't seem to find a way to exclude the latest one while chaining prev_articles
.
How would you do it?
Upvotes: 0
Views: 35
Reputation: 22449
try:
articles = Article.objects.all().order_by('-created')[1:]
except IndexError:
articles = Article.objects.none()
Upvotes: 2