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
Python JSON operation - conversion between JSON, python objects, and custom objects
Preface API When testing ,Requ
2022 Summer Practice (Django Tutorial Learning Record) (5th week 4) P58 content review and knowledge sorting
P58 Content Review and Knowled