#接口
#引用分页模块
from django.core.paginator import Paginator
#引用json格式
import json
def jiekou(request):
#请求方式为get
if request.method=='GET':
#新建列表遍历存入数据库数据
new_list=[]
all=Car.objects.values()
for the_car in all:
new_list.append(the_car)
#获取limit,page暂时用10,1
# limit=request.GET.get('limit')
# page=request.GET.get('page')
#排序
new_list=list(set(new_list))
limit_num=Paginator(new_list,10)
page_num=limit_num.page(1)
#获取本页数据
now_page=page_num.object_list
#json格式返回前端
response = HttpResponse(json.dumps({"code":"200","message":"成功获取汽车列表","result":now_page}),content_type="application/json")
return response