[Django Code] #4926: Ordering in admin listview ignores ordering in admin options

1 view
Skip to first unread message

Django Code

unread,
Jul 19, 2007, 10:45:13 AM7/19/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
----------------------------------+-----------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: adrian
Status: new | Component: Admin interface
Version: newforms-admin | Keywords:
Stage: Unreviewed | Has_patch: 0
----------------------------------+-----------------------------------------
When I specify ordering in admin options like this:
{{{
class ArticleOptions(admin.ModelAdmin):
list_display = ('title', 'is_news', 'published_from_date')
ordering = ('is_news', 'pub_date')
}}}
Ordering set default ordering column to 'is_news', but doesn't take
'pub_date' into account.

Generally all other fields except first specified in ordering tuple are
ignored.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926>
Django Code <http://code.djangoproject.com/>
The web framework for perfectionists with deadlines

Django Code

unread,
Jul 19, 2007, 10:50:28 AM7/19/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+--------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: adrian
Status: new | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------+--------------------------------------
Changes (by Glin <gl...@seznam.cz>):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0

Comment:

It is because query.order_by rewrites previous ordering. In this case, it
is on this line:
{{{
qs = qs.order_by(order_type + lookup_order_field)
}}}
So ordering from 'ordering' admin options are not taken in account (and
'ordering' from Meta, too).

I created a patch for this.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:1>

Django Code

unread,
Jul 19, 2007, 10:50:56 AM7/19/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+--------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: adrian
Status: new | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------+--------------------------------------
Changes (by Glin <gl...@seznam.cz>):

* has_patch: 0 => 1

Comment:



--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:2>

Django Code

unread,
Oct 23, 2007, 6:35:06 AM10/23/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+--------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------+--------------------------------------
Changes (by Glin <gl...@seznam.cz>):

* status: closed => reopened
* resolution: fixed =>

Comment:

Unfortunately this did not solve the problem.

Problem is that any order_by() call deletes ordering of previous
order_by() call (e.g. qs.order_by('is_news').order_by('pub_date') is the
same as qs.order_by('pub_date') ).

So problem must be fixed in code of ChangeList class, because there is the
last call of order_by method. (as in my patch)

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:5>

Django Code

unread,
Oct 24, 2007, 1:08:30 PM10/24/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+--------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------+--------------------------------------
Comment (by ramiro):

See ticket #5673 and this discussion http://groups.google.com/group
/django-developers/browse_frm/thread/c74afae800fda0b9?tvc=1 for a
discussion about multi-column ordering in the admin UI (it's not about the
admin app {{{ordering}}} option bout about the model's {{{Meta.ordering}}}
setting though).

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:6>

Django Code

unread,
Oct 25, 2007, 3:59:15 AM10/25/07
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+--------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: | Stage: Unreviewed
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------+--------------------------------------
Comment (by Glin <gl...@seznam.cz>):

I looked at it, initial comment is nearly about the same issue as this
ticket (later in discussion, there is mentioned multi column sorting in
way that user can influence these sorting columns.)

My patch only solves first issue, so admin still sorts primary according
to one column selected by user, and other sorting columns are immutable
(they are specified in model_admin.ordering). So it is only small (one and
half line) patch, so way don't use this?

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:7>

Django Code

unread,
Mar 17, 2008, 11:32:26 AM3/17/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+--------------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: nfa-someday | Stage: Someday/Maybe
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-------------------------------------+--------------------------------------
Changes (by anonymous):

* stage: Unreviewed => Someday/Maybe

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:9>

Django Code

unread,
Mar 19, 2008, 1:11:25 AM3/19/08
to djang...@holovaty.com, ja...@jacobian.org, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
------------------------------------------+---------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Component: Admin interface
Version: newforms-admin | Resolution:
Keywords: nfa-someday nfa-changelist | Stage: Someday/Maybe
Has_patch: 1 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
------------------------------------------+---------------------------------
Changes (by ales_zoulek):

* keywords: nfa-someday => nfa-someday nfa-changelist

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:10>

Django Code

unread,
Jul 19, 2008, 11:37:02 PM7/19/08
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: Admin interface | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Changes (by smo...@andstuff.org):

* cc: smo...@andstuff.org (added)
* version: newforms-admin => SVN

Comment:

Me-too (now that nfa has hit the trunk). Most of my models have multiple
fields in their ordering. Changing the version of this ticket to 'SVN'
now that nfa is on trunk.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:12>

Django

unread,
Oct 16, 2008, 1:57:10 PM10/16/08
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Changes (by xiongchiamiov):

* cc: james.m.pea...@gmail.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:13>
Django <http://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 15, 2008, 7:52:04 AM12/15/08
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Changes (by Jonas):

* cc: dja...@vonposer.de (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:14>

Django

unread,
Jul 20, 2009, 1:03:57 PM7/20/09
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by Xiong Chiamiov):

This seems like an easy fix without many consequences to me. It would be
nice to either get this merged in (or a "this should go in, but the patch
needs work") or a wontfix close. If the previous is the case, I'm willing
to work on it. If the latter, then it'll just be nice to have a
resolution of some sort.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:15>

Django

unread,
Jul 24, 2009, 4:09:56 AM7/24/09
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by fabiocorneti):

This is a very useful feature (especially for django-mptt users) and the
patch seems quite unobtrusive, +1 for merging it into trunk

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:16>

Django

unread,
Sep 12, 2009, 1:57:53 AM9/12/09
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by bendavis78):

If anyone is interested, I've submitted a patch for a proposed UI for
sorting by multiple fields. This would also fix this particular issue.

See here: #11868

Any feedback is appreaciated.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:17>

Django

unread,
Feb 4, 2010, 5:17:29 AM2/4/10
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by akaihola):

Replying to [comment:8 brosner]:
> This ticket isn't critical to the merge of newforms-admin since it is an
enhancement. Tagging with nfa-someday.

I'd consider this a little more than an enhancement. As Eric B noted, it's
confusing that a tuple/list of fields is required but all but the first
field are ignored.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:18>

Django

unread,
Feb 17, 2010, 2:30:52 AM2/17/10
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by Mogga <r...@moggach.com>):

I agree.

This for me, is most certainly a bug...

For example, I have a set of teams and each team has a set of players with
numbers.
I would like to order them by team and then by number but the following
does not do that.

{{{
ordering=('team','number')
}}}

In fact any number of fields are irrelevant given it really only ever
orders like this:

{{{
ordering=('team')
}}}

The behavior is just wrong so for me it's a bug, not an enhancement.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:19>

Django

unread,
Feb 17, 2010, 2:36:49 AM2/17/10
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Changes (by Mogga <r...@moggach.com>):

* cc: r...@moggach.com (added)

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:20>

Django

unread,
Feb 17, 2010, 2:43:11 AM2/17/10
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
--------------------------------------------+-------------------------------
Reporter: Glin <gl...@seznam.cz> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Stage: Someday/Maybe | Has_patch: 1
Needs_docs: 0 | Needs_tests: 0
Needs_better_patch: 0 |
--------------------------------------------+-------------------------------
Comment (by Mogga <r...@moggach.com>):

that patch works perfectly here...

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:21>

Django

unread,
Feb 23, 2011, 7:18:32 AM2/23/11
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------------------+--------------------------
Reporter: Glin <glin@…> | Owner: nobody
Status: reopened | Milestone:
Component: django.contrib.admin | Version: SVN
Resolution: | Keywords: nfa-someday nfa-changelist
Triage Stage: Someday/Maybe | Has patch: 1
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 |
-------------------------------------------------+--------------------------
Changes (by patrickk):

* cc: patrickk (added)


--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:22>

Django

unread,
Apr 4, 2011, 7:51:46 PM4/4/11
to djang...@holovaty.com, django-...@googlegroups.com
#4926: Ordering in admin listview ignores ordering in admin options
-------------------------------------+-------------------------------------
Reporter: Glin | Owner: nobody
<glin@…> | Status: closed
Type: Bug | Component: contrib.admin
Milestone: | Severity: Normal
Version: SVN | Keywords: nfa-someday nfa-
Resolution: duplicate | changelist
Triage Stage: | Has patch: 1
Someday/Maybe | Needs tests: 0
Needs documentation: 0 |
Patch needs improvement: 0 |
-------------------------------------+-------------------------------------
Changes (by julien):

* status: reopened => closed
* resolution: => duplicate


Comment:

Closing as a duplicate of #11868 which, although newer, suggests a better
approach UI-wise and has a more recent patch.

--
Ticket URL: <http://code.djangoproject.com/ticket/4926#comment:24>

Reply all
Reply to author
Forward
0 new messages