Python Forum

Full Version: filtering on a paginated queryset
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This code combines filtering and pagination, the pagination works, but I can't understand how to get the filtering to work. The containerlist gets filtered and is assigned to filtered_qs, I need to access this queryset in the html code which follows
def containerpage(request):
    container_list = Container.objects.all()
    filtered_qs = filters.ContainerFilter(request.GET, queryset=container_list).qs
    paginator = Paginator(filtered_qs, 10)
    page = request.GET.get('page')
        response =
    except PageNotAnInteger:
        response =
    except EmptyPage:
        response =
    return render(request,'search/container_filter.html',{'response': response})
HTML snippet
    <div class="form-group col-sm-4 col-md-3">
          {{ response.form.sample_id.label_tag }}
          {% render_field responce.form.sample_number class="form-control" %}