Answer the question
In order to leave comments, you need to log in
Why does __init__() takes 2 positional arguments but 4 were given error in django?
views.py
class ArchiveReports(ListView):
context_object_name = 'articles'
template_name = 'main_application/archive-reports-page.html'
def get_queryset(self):
articles = Articles.objects.all()
# Отбираем первые 10 статей
paginator = Paginator(articles, 2)
page = self.request.GET.get('page')
try:
articles = paginator.page(page)
except PageNotAnInteger:
articles = paginator.page(1)
except EmptyPage:
articles = paginator.page(paginator.num_pages)
return articles
path('archive/', views.ArchiveReports.as_view(), name='archive_page'),
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