pagination

This commit is contained in:
caoqianming 2020-06-08 14:07:23 +08:00
parent c87b145151
commit 381179579c
2 changed files with 9 additions and 2 deletions

View File

@ -115,8 +115,10 @@ USE_L10N = True
USE_TZ = True USE_TZ = True
# 跨域配置 # 跨域配置
CORS_ALLOW_CREDENTIALS = False
CORS_ORIGIN_ALLOW_ALL = True CORS_ORIGIN_ALLOW_ALL = True
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/ # https://docs.djangoproject.com/en/3.0/howto/static-files/
@ -146,8 +148,7 @@ REST_FRAMEWORK = {
'rest_framework.filters.SearchFilter', 'rest_framework.filters.SearchFilter',
'rest_framework.filters.OrderingFilter' 'rest_framework.filters.OrderingFilter'
], ],
'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.PageNumberPagination', 'DEFAULT_PAGINATION_CLASS': 'utils.pagination.MyPagination',
'PAGE_SIZE': 10,
'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S', 'DATETIME_FORMAT': '%Y-%m-%d %H:%M:%S',
'DATE_FORMAT': '%Y-%m-%d', 'DATE_FORMAT': '%Y-%m-%d',
'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema', 'DEFAULT_SCHEMA_CLASS': 'rest_framework.schemas.coreapi.AutoSchema',

View File

@ -0,0 +1,6 @@
from rest_framework.pagination import PageNumberPagination
class MyPagination(PageNumberPagination):
page_size = 10
page_size_query_param = 'limit'