Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#18086 closed Cleanup/optimization (fixed)

Restore '-pk' as the default order in admin changelist

Reported by: Julien Phalip Owned by: nobody
Component: contrib.admin Version: 1.4
Severity: Release blocker Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: yes

Description

Until Django 1.3, the admin changelist's default order was '-pk': https://code.djangoproject.com/browser/django/branches/releases/1.3.X/django/contrib/admin/views/main.py#L146

As some point in the 1.4 release cycle (probably when multi-sort was enabled) the default order was dropped, which caused the non-deterministic order issue in #17198. That ticket was fixed by re-introducing the primary key in the list of ordering fields to enforce a deterministic order (in all cases, not just for the default order) in r17635.

Now everything works fine, however the default order is 'pk'. Partially for backwards compatibility, but primarily for a better user experience, I think we should restore '-pk' as the default order. The main reason is that one usually care more about the most recent items, so it's generally best if those appear at the top of the first page of the changelist.

The attached patch does just that. I suggest also porting it to 1.4.X for backwards compatibility.

Attachments (1)

18086.admin-changelist-order-pk-desc.diff (7.7 KB ) - added by Julien Phalip 12 years ago.

Download all attachments as: .zip

Change History (7)

by Julien Phalip, 12 years ago

comment:1 by Claude Paroz, 12 years ago

Has patch: set
Triage Stage: UnreviewedAccepted

Fine for me.

comment:2 by Anssi Kääriäinen, 12 years ago

If this is applied then we should back-patch this as a fix to a regression in 1.4. Having it different in 1.3 than 1.4 and again different in 1.5 doesn't sound like a good idea.

I quickly looked through the patch and found no problems. The full test suite passes on SQLite. So, fine for me too.

comment:3 by Simon Charette, 12 years ago

Triage Stage: AcceptedReady for checkin

comment:4 by Julien Phalip, 12 years ago

@akaariai: Yes that's what I suggested above. It's a minor "regression" (or rather an uncontroversial change in behavior :-), which I too think should be corrected in 1.4.1. I'll push the patch to the 2 branches.

comment:5 by Julien Phalip, 12 years ago

Resolution: fixed
Status: newclosed

In [17881]:

Fixed #18086 -- Restored '-pk' as the default order in the admin changelist. This rectifies a slight change in behavior introduced in Django 1.4 and r17635.

comment:6 by Julien Phalip, 12 years ago

In [17882]:

[1.4.X] Fixed #18086 -- Restored '-pk' as the default order in the admin changelist. This rectifies a slight change in behavior introduced in Django 1.4 and r17635.

Backport of r17881 from trunk.

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