Set the distribution and the number of pages
stay settting.py Add
REST_FRAMEWORK = {
'DEFAULT_PAGINATION_CLASS':[
'rest_framework.Pagination.PageNumberPaginaion',
'PAGE_SIZE':100,
# notes : The number of pages cannot be modified
],
}
from rest_framework.Pagination import PageNumberPagination
class Paging class name (PageNumberPagination):
page_size = 10 # The default is 10 strip
page_query_param = 'page'
page_size_query_param = 'size'
max_page_size = 100 # At most... Can be set 100 strip
from .pagination import Paging class name
# Create your views here.
class Library name ViewSet(ModelViewSet):
...
pagination_class = Paging class name
http://localhost:8000/api/students/?page=nu&size=nu
Preface API When testing ,Requ
P58 Content Review and Knowled