Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#18086 closed Cleanup/optimization (fixed)

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

Reported by: julien 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 3 years ago.

Download all attachments as: .zip

Change History (7)

Changed 3 years ago by julien

comment:1 Changed 3 years ago by claudep

  • Has patch set
  • Triage Stage changed from Unreviewed to Accepted

Fine for me.

comment:2 Changed 3 years ago by akaariai

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 Changed 3 years ago by charettes

  • Triage Stage changed from Accepted to Ready for checkin

comment:4 Changed 3 years ago by julien

@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 Changed 3 years ago by julien

  • Resolution set to fixed
  • Status changed from new to closed

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 Changed 3 years ago by julien

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