Opened 8 years ago

Closed 8 years ago

#6929 closed (invalid)

admin interface ignores multi-column ordering if it is set by default in the model

Reported by: shamardin@… Owned by: nobody
Component: contrib.admin Version: master
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:


Even if there are several fields specified for ordering by default in Meta ordering or Admin ordering, the resulting view in the admin interface is ordered only by the first field.

How to reproduce:

Create a new app with these

from django.db import models

class Test(models.Model):
  a = models.CharField(max_length=5)
  b = models.CharField(max_length=5)

  def __unicode__(self):
    return 'a=%s,b=%s' % (self.a, self.b)

  class Meta:
    ordering = ['-b', '-a']

  class Admin:

Populate with test data from shell:

In [1]: from test.models import *

In [2]: t1 = Test(a='1', b='10')

In [3]: t2 = Test(a='2', b='10')

In [4]: t3 = Test(a='1', b='11')

In [5]: t4 = Test(a='2', b='11')

In [6]:

In [7]:

In [8]:

In [9]:

Observe the correct ordering:

In [10]: Test.objects.all()
Out[10]: [<Test: a=2,b=11>, <Test: a=1,b=11>, <Test: a=2,b=10>, <Test: a=1,b=10>]

Now browse the Test model in the admin interface and observe the incorrect ordering:


Change History (1)

comment:1 Changed 8 years ago by ramiro

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

This is intended and documented behavior. See the bottom of the relevant documentation section (

Note: See TracTickets for help on using tickets.
Back to Top