title: How do I make a button click change the django order_by?
body: <p>Here's my views.py function.</p>
  <pre><code>def publications(request):
      if request.method == 'POST':
          publications = UserPublications.objects.all().order_by('status_date')
      else:
          publications = UserPublications.objects.all().order_by('contributors')
  
  
      context = {'publications': publications}
      return render(request, 'users/publications.html', context)
  </code></pre>
  <p>Here's my publications.html:</p>
  <pre><code>&lt;button type=&quot;submit&quot; method=&quot;POST&quot;&gt;Filter By Date&lt;/button&gt;
  &lt;ol  class=&quot;text&quot;&gt;
      {% for publication in publications %}
          &lt;div&gt;{{publication.text}}&lt;/div&gt;
      {% endfor %}
  &lt;/ol&gt;
  </code></pre>
  <p>I want a button to be clicked on and if someone clicks on it it changes to filter by date instead of by contributors (both attributes of my model). How would I do that? Right now I have no errors but when I click on the button it's not updating the sorting on my objects. Thanks in advance.</p>