Django在特定数字或索引后检索数据
我的视图中有两个渲染上下文:Django在特定数字或索引后检索数据,django,django-views,Django,Django Views,我的视图中有两个渲染上下文: 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' :
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)
在第二个('allposts')中,我希望获得所有对象,而不使用第一个fve
如何操作?使用切片作为
AllOtherPosts=Post.objects.order\u by(“-date”).all()[5: