Issue
please how can i determine number of objects/page show(not number of pages) in Django when using ListView Pagination.
that's my code in Views.py
:
from django.shortcuts import render
from django.views.generic import ListView, DetailView
from .models import Post
class PostList(ListView):
model=Post
context_object_name='all_post'
ordering=['-created_at']
thank you!
Solution
Just add paginate_by = <number of items in a page>
to your view.
For example:
from django.shortcuts import render
from django.views.generic import ListView, DetailView
from .models import Post
class PostList(ListView):
model=Post
context_object_name='all_post'
ordering=['-created_at']
paginate_by = 10 # 10 items in a page
Answered By - black
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.