title: How to sort list_filter labels for foreign key filters in Django admin?
body: <p>List_filter labels for foreign key filters in django admin are always ordered by id and that can cause a pretty mess when there are many filters in the list.</p>
  
  <p>I have been searching for simple solution how to order those labels alphabetically or by date for some time now. It seemed that besides of using FilterSpec there is no solution for it. </p>
  
  <p>Until I did this.</p>
  
  <p>I have changed the template for filter.html (put it in admin folder in your templates directory) so it looks like this (found it somewhere on django snippets I guess):</p>
  
  <pre><code>{% load i18n %}
  &lt;h3&gt;{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}&lt;/h3&gt;
  &lt;div align="right"&gt;
    &lt;select onChange="javascript:window.location = this.options[this.selectedIndex].value;" style="width: 80%"&gt;
      {% for choice in choices %}
        &lt;option {% if choice.selected %}selected{% endif %} value="{{ choice.query_string|iriencode }}"&gt;
          {{ choice.display }}
        &lt;/option&gt;
      {% endfor %}
    &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>And then I used 'dictsort:"name"' template tag on for loop so the template finally looked like this:</p>
  
  <pre><code>{% load i18n %}
  &lt;h3&gt;{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}&lt;/h3&gt;
  &lt;div align="right"&gt;
    &lt;select onChange="javascript:window.location = this.options[this.selectedIndex].value;" style="width: 80%"&gt;
      {% for choice in choices|dictsort:"display" %}
        &lt;option {% if choice.selected %}selected{% endif %} value="{{ choice.query_string|iriencode }}"&gt;
          {{ choice.display }}
        &lt;/option&gt;
      {% endfor %}
    &lt;/select&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>I have used select drop-down since I had many labels, but it can be used on the standard 'ul' list too. Now I finally have all my foreign key based filters ordered alphabetically (and it works even if using dates).</p>
  
  <p>If you need reversed dosting there is dictsortreversed template tag for that.</p>
  
  <p>Hope that this helps someone.</p>