示例#1
0
def conserto_list(request):
    filters = {}
    add_filter(request, filters, 'marca', 'modelo__marca__descricao')
    add_filter(request, filters, 'modelo', 'modelo__descricao')
    add_filter(request, filters, 'defeito', field_lookup='')
    queryset = Conserto.objects.filter(**filters)
    paginator = Paginator(queryset, 20, body=5)
    page = request.POST.get('page', 1)
    try:
        consertos = paginator.page(page)
    except PageNotAnInteger:
        consertos = paginator.page(1)
    except EmptyPage:
        consertos = paginator.page(paginator.num_pages)
    return render(request, 'core/conserto_list.html', {'consertos': consertos})
示例#2
0
def conserto_list(request):
    filters = {}
    add_filter(request, filters, 'marca', 'modelo__marca__descricao')
    add_filter(request, filters, 'modelo', 'modelo__descricao')
    add_filter(request, filters, 'defeito', field_lookup='')
    queryset = Conserto.objects.filter(**filters)
    paginator = Paginator(queryset, 20, body=5)
    page = request.POST.get('page', 1)
    try:
        consertos = paginator.page(page)
    except PageNotAnInteger:
        consertos = paginator.page(1)
    except EmptyPage:
        consertos = paginator.page(paginator.num_pages)
    return render(request, 'core/conserto_list.html', {'consertos': consertos})