title: dynamically set per_page in django-tables2
body: <p>Websites often allow the user to specify how many items to show per page in a paginated table.  Iwould like to do this with django-tables2.</p>
  
  <p>I could add a "Show [ 5 | 10 | 50 ] per page" select box to collect a per_page parameter from the user.</p>
  
  <p>However, the "Previous" and "Next" buttons in the table template are hyperlinks, with a hardcoded value for per_page, e.g.:</p>
  
  <pre><code>&lt;a href="?per_page=5&amp;page=5"&gt;Next&lt;/a&gt;
  </code></pre>
  
  <p>I am thinking the only way to make this dynamic would be to use javascript, e.g.:</p>
  
  <pre><code>&lt;span onclick="get_table_page(5)"&gt;Next&lt;/span&gt;
  </code></pre>
  
  <p>Where the functions get_table_page() can retrieve the per_page parameter from the select box.</p>
  
  <p>Is that the best way to do it?  Or is there a way without javascript?</p>
  
  <p>UPDATE: No answer to the question (how to change per_page for Previous/Next page) but, as accepted answer points out, user can reload the current page with changed per_page parameter, e.g.:</p>
  
  <pre><code>&lt;p&gt;Show [ &lt;a href="{% querystring "per_page"=5  %}"&gt;5&lt;/a&gt;
          | &lt;a href="{% querystring "per_page"=20 %}"&gt;20&lt;/a&gt;
          | &lt;a href="{% querystring "per_page"=50 %}"&gt;50&lt;/a&gt;
          ] Items&lt;/p&gt;
  </code></pre>
  
  <p>With thanks and best wishes</p>
  
  <p>Ivan</p>