title: Pagination with ordering and other get variables
body: <p>In a class based ListView, while rendering i want to dynamically change the no of items shown per page and the sorting order of those items.</p>
  <p>I referred to <a href="https://stackoverflow.com/questions/2047622/how-to-paginate-django-with-other-get-variables">this</a> question and the answer by skoval00 works for me when i change the ordering and change the pages. But as soon as i change the no of items per page, my ordering is lost.</p>
  <p>For ex: my generic view links to <code>http://127.0.0.1:8000/marketplace/</code>.</p>
  <p>If i set the pagination to 10 items per page.</p>
  <p>The url changes to <code>http://127.0.0.1:8000/marketplace/?paginate_by=10</code></p>
  <p>But now if i change my ordering too, i expect something like</p>
  <p><code>http://127.0.0.1:8000/marketplace/?paginate_by=10&amp;ordering=end_date</code></p>
  <p>but i get</p>
  <p><code>http://127.0.0.1:8000/marketplace/?ordering=end_date</code></p>
  <p>And the pagination changes to the default value.
  Same thing happens vice-versa. If i order first and then change pagination, then i lose the ordering once the pagination changes.</p>
  <p>How do i preserve the first argument while adding the second one?</p>
  <p>Here is the relevant class in views.py</p>
  <pre><code>class CatalogueListView(ListView):
      model = Catalogue
      context_object_name = 'catalogues'
      template_name = 'marketplace/catalogue_list.html'
      paginate_by = 5
      ordering = ['end_date']
  
      def get_queryset(self):
          if self.request.GET.get('ordering'):
              ordering = self.request.GET.get('ordering')
          else:
              ordering = 'end_date'
  
          query_set = Catalogue.objects.filter(admin_approved=True, end_date__gt=timezone.now()).order_by(ordering)
          return query_set
   
      
      def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          
          if self.request.GET.get('paginate_by'):
              context['paginate_by'] = self.request.GET.get('paginate_by')
          else:
              context['paginate_by'] = self.paginate_by
          
          if self.request.GET.get('ordering'):
              context['ordering'] = self.request.GET.get('ordering')
          else:
              context['ordering'] = self.ordering
  
  
          return context
  
      def get_paginate_by(self, queryset):
         
          return self.request.GET.get('paginate_by', self.paginate_by)
      
      
  </code></pre>
  <p>ans</p>