title: Django ListView - Form to filter and sort
body: <p><strong>My Goal</strong></p>
  
  <ul>
  <li>A site that list all my Updates (model) in a table</li>
  <li>Dont display all models at once (pagination - maybe 10 per page)</li>
  <li>Filter and sort the list</li>
  </ul>
  
  <p><strong>My thoughts</strong></p>
  
  <ul>
  <li>I can use ListView to get a set of all my Updates</li>
  <li>Use paginate_by = 10</li>
  <li>Use a form to set order_by or filter in my QuerySet</li>
  </ul>
  
  <p><strong>My Problem</strong></p>
  
  <p>I am not sure how to add an form to modify my QuerySet with filter and sortings. My Idea was to modify the Query in get_queryset with additional filter and order_by.</p>
  
  <p><strong>My View</strong></p>
  
  <pre><code>class MyView(ListView):
      model = Update
      template_name = "updates/update.html"
      paginate_by = 10
  
      def get_queryset(self):
          return Update.objects.filter(
              ~Q(state=Update.STATE_REJECTED),
              ~Q(state=Update.STATE_CANCELED),
              ~Q(state=Update.STATE_FINISHED),
          ).order_by(
              'planned_release_date'
          )
  </code></pre>
  
  <p><strong>My Idea</strong></p>
  
  <p>Something like this. I know it's not working like this ... just to illustrate</p>
  
  <pre><code>class MyView(ListView):
      model = Update
      template_name = "updates/update.html"
      paginate_by = 10
  
      def post(self, request, *args, **kwargs):
          new_context = Update.objects.filter(
              request.POST.get("filter"),
          ).order_by(
              request.POST.get("sorting"),
          )
  
      def get_queryset(self):
          return Update.objects.filter(
              ~Q(state=Update.STATE_REJECTED),
              ~Q(state=Update.STATE_CANCELED),
              ~Q(state=Update.STATE_FINISHED),
          ).order_by(
              'planned_release_date'
          )
  </code></pre>