DRF后台接收参数进行分页接口查询
from rest_framework.response import Response
from rest_framework.views import APIView
from .models import taskDateDB
from .Serializer import taskDateDB_Serializer
class get_paging(APIView):
"""获取分页数据"""
def get(self,request):
'''
:param page: 页码
:param amount: 每页的量
:return: total :全部的条数
'''
page = int(request.GET.get("page"))
amount = int(request.GET.get("amount").strip('/'))
endCount = page * amount
startCount = endCount - amount
item = {
}
try:
total = taskDateDB.objects.all().count()
if endCount < total:
result = taskDateDB.objects.all()[startCount:endCount]
else:
result = taskDateDB.objects