Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Django在特定数字或索引后检索数据_Django_Django Views - Fatal编程技术网

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: