Django分页查询

@login_required()
def show_page(request):
    """
    分页
    :param request:
    :return:
    """
    limit = int(request.GET.get("limit"))
    start = int(request.GET.get("start"))
    page = int(request.GET.get("page"))
    search = request.GET.get("search")

    data_list = ProductVulnInfo.objects.filter(isdelete=False). values("").order_by()
    paginator = Paginator(data_list, limit)
    count = paginator.count
    data = paginator.page(page)
    result = []
    row = {
        "id": item['id'],
         "": item[''],
         "": item[''],
         "": str(item[''].strftime('%Y-%m-%d')),
         "": str(item[''].strftime('%Y-%m-%d')),
         "": item[''],
         "": item[''],
         "":,
     }
    result.append(row)
    response = {'data': result, 'limit': limit, 'page': start, 'total': count}
    return JsonResponse(response)

  

posted @ 2020-03-25 13:53  sevck  阅读(264)  评论(0编辑  收藏