Leo
Leo

Reputation: 63

Django Retrive data after a specific number or index

i have two rendered contexts in my view:

def PostHomeView(request):
RecentPost = Post.objects.order_by("-date").all()[:5]
AllOtherPosts = Post.objects.order_by("-date").all()
template_name = 'lista_post.html'
context = {**strong text**
    'recentposts' : RecentPost,
    'allposts' : AllOtherPosts
}
return render(request,template_name,context)

in the second one ('allposts') i would like to get all objcects without the first fve how can i do it?

Upvotes: 1

Views: 24

Answers (1)

JPG
JPG

Reputation: 88539

Use slicing as AllOtherPosts = Post.objects.order_by("-date").all()[5:]

Upvotes: 1

Related Questions