title: Django: django-tables2 pagination and filtering
body: <p>I have a working table generated by django-tables2:</p>
  
  <pre><code>my_filter = TestFilter(request.POST) 
  table = TestTable(TestObj.objects.all(), order_by="-my_date")
  RequestConfig(request, paginate={"per_page": 10}).configure(table)
  return render(request, 'test_app/index.html', {'table': table, 'my_filter': my_filter})
  </code></pre>
  
  <p>The above code returns a table with hundreds of objects that are neatly paginated with 10 items per page. When I click "Next" at the bottom of the table, pagination works well and I can navigate through different pages.  However, I noticed the following behavior:</p>
  
  <ul>
  <li>Click on <code>my_filter</code> which displays a subset of the original unfiltered table</li>
  <li>Click "Next" on the bottom of the filtered table will result in displaying the 2nd page of the unfiltered table</li>
  <li>Click on <code>my_filter</code> again displays the 2nd page of the filtered table</li>
  </ul>
  
  <p>I would like the filter to persist while navigating different pages. I found a similar question <a href="https://stackoverflow.com/questions/14674063/django-persist-the-filter-with-paginator">here</a>. That solution indicates that the  html code needs to be altered. However, in my case django-tables2 is generating the html.</p>
  
  <p>How can I correctly implement pagination with filtering using django-tables2?</p>
  
  <p><strong><em>-Update-</em></strong></p>
  
  <p>I've tried using GET instead of POST:</p>
  
  <pre><code>if request.method == 'GET':
      my_filter = TestFilter(request.GET)
      my_choice = my_filter.data['my_choice']
      table = TestTable(TestObj.objects.filter(choice=my_choice), order_by="-my_date")
      RequestConfig(request, paginate={"per_page": 10}).configure(table)
      return render(request, 'test_app/index.html', {'table': table, 'my_filter': my_filter})
  </code></pre>
  
  <p>My template:</p>
  
  <pre><code>&lt;form action="" method="get"&gt; {% csrf_token %}
      {{ my_filter }} &lt;input type="submit" value="Apply Filter"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>This results in a KeyError due to <code>my_choice</code> not existing in GET. As a result the page does not even load.</p>