title: Django pagination -- maintaining filter and order by
body: <p>I've a small Django project <a href="https://github.com/Johnnyboycurtis/basic-pagination/tree/master" rel="nofollow noreferrer">basic-pagination</a>. There is one model, one form and two views (list view, form view). User submits data in the form view, then the data is displayed in the list view. Pagination is enabled to only display 5 posts at a time.</p>
  
  <p>What I've implemented is a form with a GET response to get the data I want to display (e.g. name, date). See code below</p>
  
  <pre><code>class FormListView(ListView):
      model = models.ToDoList
      paginate_by = 5  # if pagination is desired
      template_name = 'pagination/listview.html'
      context_object_name = 'forms'
  
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['title'] = 'Form List View'
          context['filter_form'] = forms.FilterListView(self.request.GET)
          return context
  
      def get_queryset(self):
          queryset = models.ToDoList.objects.all().order_by('-id')
          name = self.request.GET.get('name')
          if name:
              queryset = queryset.filter(name=name)
          order_by = self.request.GET.get('order_by')
          if order_by:
              queryset = queryset.order_by(order_by)
          print(queryset)
          return queryset
  </code></pre>
  
  <p>The <strong>problem</strong> is that the class based view <a href="https://docs.djangoproject.com/en/3.0/ref/class-based-views/generic-display/#listview" rel="nofollow noreferrer"><code>ListView</code></a> calls the method <a href="https://github.com/django/django/blob/master/django/views/generic/list.py#L21" rel="nofollow noreferrer"><code>get_queryset</code></a> if you are moving from page <code>1</code> to page <code>2</code> and thus losing the filtered queryset I wanted.</p>
  
  <p>How can I maintain the filtering throughout the pagination process?</p>