title: How to reorder dropdowns in django-admin inlines?
body: <p>I'm trying to give some order to our django admin dashboard. At the moment I am able to order dropdowns by the field <code>name</code> using this code in <code>MyModelAdmin</code>:</p>
  
  <pre><code>def formfield_for_foreignkey(self, db_field, request, **kwargs):
      if db_field.name == "program":
          kwargs["queryset"] = models.ProgramModel.objects.all().order_by('name')
      return super(MyModelAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs)
  </code></pre>
  
  <p>So, when I go to the <code>MyModel</code> I see the dropdown alphabetically ordered like in this image:</p>
  
  <p><a href="https://i.stack.imgur.com/Wv7MX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wv7MX.png" alt="ordered list in dropdown"></a></p>
  
  <p>T)he problem is that if I bring that model as an Inline in a different model, it is not ordered anymore:</p>
  
  <p><a href="https://i.stack.imgur.com/xDSG5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xDSG5.png" alt="unordered list in inline dropdown"></a></p>
  
  <p>How can I have that dropdown ordered also in the inline element??</p>
  
  <p>I already tried adding <code>ordering</code> to my <code>MyModel</code> meta class and it works, but I would like this to affect only the admin page and to be completely decoupled from the model.</p>
  
  <hr>
  
  <p>The Inline class is just this:</p>
  
  <pre><code>class MyInline(admin.TabularInline):
      extra = 1
      model = models.Program.members.through
  </code></pre>
  
  <p>So I have the model <code>Program</code> with a m2m field to <code>Member</code>, through the model <code>Membership</code> (that I've been calling here <code>MyModel</code>).</p>