分页显示,携带参数

前台

       

后台:

def showflightinfo(request):
    isdate = request.GET.get('publish_date')
     nowdate = '20' + time.strftime("%y-%m-%d")
    if isdate == '' or isdate is None:
    isdate = nowdate
    p = request.GET.get('page', 1)
    if p == False or p == 0:
            p = 2
    flights = FlightNo.objects.filter(nowdate=str(isdate))
    flights_list = []
    if flights != None:
            paginator = Paginator(flights, 10)
            page = int(p)
    try:
        flights_list = paginator.page(page)
    except PageNotAnInteger:
        flights_list = paginator.page(1)
    except InvalidPage:
        return HttpResponse('找不到页面')
    except EmptyPage:
        flights_list = paginator.page(paginator.num_pages)

    return render(request, 'XXXX/dataview_XXXX.html', {
    'isdate': isdate,
    'flights_list': flights_list,
})

你可能感兴趣的:(分页显示,携带参数)