1π
β
It seems the actual page was not processed and is missing.
Try to add this line:
page_obj = paginator.get_page(page)
And pass it to the context. So the full view would be:
def home(request):
page = request.GET.get('page', 1)
paginator = Paginator(Post.objects.all(), 2)
page_obj = paginator.get_page(page)
page_range = paginator.get_elided_page_range(number=page)
context = {'page_range': page_range, 'page': page, 'paginator': paginator, 'page_obj': page_obj}
return render(request, 'blog/home.html', context)
π€Brian Destura
Source:stackexchange.com