Sample code may be wrong
YiAnCN opened this issue · 5 comments
YiAnCN commented
p = Paginator(objects, request=request)
in views.py may need to add the number of paged pages,
That is modified as p = Paginator(objects, number, request=request)
Otherwise it will report this error: __init__() missing 1 required positional argument: 'per_page'
avremel commented
Ran into the same issue.
chaying2016 commented
same here
harolCalzada commented
any solution?
YiAnCN commented
@harolCalzada
p = Paginator(objects, request=request)
Just add the number of pages you need to page in this line of code.
vustudymaterial commented
def HomeView(request): datas = Article.objects.all() all_post = Paginator(datas,3) page_number = request.GET.get('page') page_obj = Paginator.get_page(page_number) return render(request,'index.html',{'page_obj':page_obj})