Answer the question
In order to leave comments, you need to log in
Why don't pagination methods work?
index.html
<span class="current">
Страница {{ page }} из{{ page.paginator.num_pages }}.
</span>
def index(request):
news = News.objects.order_by("date")
paginator = Paginator(news, 16)
page = request.GET.get('page')
try:
posts = paginator.page(page)
except PageNotAnInteger:
posts = paginator.page(1)
except EmptyPage:
posts = paginator.page(paginator.num_pages)
context = {
'page': page,
'posts': posts
}
return render(request, 'index.html', context)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question