[Django] #30449: Ordering problem in admin.RelatedFieldListFilter and admin.RelatedOnlyFieldListFilter

27 views
Skip to first unread message

Django

unread,
May 6, 2019, 10:04:16 AM5/6/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz | Owner: nobody
Pfeiffer |
Type: Bug | Status: new
Component: | Version: 2.2
contrib.admin | Keywords:
Severity: Normal | RelatedFieldListFilter,
| RelatedOnlyFieldListFilter,
Triage Stage: | ordering
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 1 |
-------------------------------------+-------------------------------------
RelatedFieldListFilter doesn't fall back to the ordering defined in
Model._meta.ordering.

Ordering gets set to an empty tuple in
https://github.com/django/django/blob/2.2.1/django/contrib/admin/filters.py#L196
and unless ordering is defined on the related model's ModelAdmin class it
stays an empty tuple. IMHO it should fall back to the ordering defined in
the related model's Meta.ordering field.

RelatedOnlyFieldListFilter doesn't order the related model at all, even if
ordering is defined on the related model's ModelAdmin class.
That's because the call to field.get_choices
https://github.com/django/django/blob/2.2.1/django/contrib/admin/filters.py#L422
omits the ordering kwarg entirely.

--
Ticket URL: <https://code.djangoproject.com/ticket/30449>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 6, 2019, 10:07:21 AM5/6/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
RelatedFieldListFilter, | Unreviewed
RelatedOnlyFieldListFilter, |
ordering |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Moritz Pfeiffer):

* Attachment "django_filter_ordering.zip" added.

Sample project illustrating the problem. Navigate to /admin/foo/book and
observer the order of Author in the list filters.

Django

unread,
May 6, 2019, 10:09:38 AM5/6/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage:
RelatedFieldListFilter, | Unreviewed
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Moritz Pfeiffer):

* Attachment "Screenshot 2019-05-06 at 15.49.17.jpg" added.

Screenshot of RelatedOnlyFieldListFilter not ordering items.

Django

unread,
May 9, 2019, 5:13:18 AM5/9/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: nobody
Type: Bug | Status: new

Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

* stage: Unreviewed => Accepted


Comment:

OK, yes, seems a reasonable suggestion if you'd like to work on it.

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:1>

Django

unread,
May 12, 2019, 2:42:17 AM5/12/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned

Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by zeynel):

* status: new => assigned
* owner: nobody => zeynel


--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:2>

Django

unread,
May 13, 2019, 2:20:53 AM5/13/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by zeynel):

* has_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:3>

Django

unread,
Jun 12, 2019, 10:00:36 AM6/12/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by felixxm):

* needs_better_patch: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:4>

Django

unread,
Jul 20, 2019, 9:01:55 AM7/20/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: 2.2
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Althalus):

* needs_better_patch: 1 => 0


Comment:

Hello. We've updated our django recently and faced this bug. For me it
seems like a quite big regression.
As I see in PR, patch was updated and appropriate tests were added too so
I suggest to consider including it in 2.2.4 and backporting to (at least)
2.1.

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:5>

Django

unread,
Jul 20, 2019, 9:08:03 AM7/20/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: master

Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by felixxm):

* version: 2.2 => master


Comment:

As far as I'm concerned it's not a regression and doesn't qualify for a
backport. It's on my list and should be fixed in Django 3.0.

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:6>

Django

unread,
Aug 12, 2019, 11:40:18 AM8/12/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution:

Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by felixxm):

* severity: Normal => Release blocker


Comment:

I closed #30703 as a duplicate. It is a regression introduced in #29835.

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:7>

Django

unread,
Aug 12, 2019, 11:41:25 AM8/12/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by felixxm):

Alternate [https://github.com/django/django/pull/11661 PR].

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:8>

Django

unread,
Aug 14, 2019, 8:30:38 AM8/14/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by tinodb):

I'd argue it ''is'' a regression. It worked before and is clearly broken
now.

Any workarounds for the moment?

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:9>

Django

unread,
Aug 14, 2019, 9:04:42 AM8/14/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by felixxm):

Replying to [comment:9 tinodb]:


> I'd argue it ''is'' a regression. It worked before and is clearly broken
now.
>
> Any workarounds for the moment?

Yes we marked this as a regression and release blocker (please check my
previous [https://code.djangoproject.com/ticket/30449#comment:7 comment]).

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:10>

Django

unread,
Aug 15, 2019, 1:31:57 AM8/15/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: assigned
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by felixxm):

`RelatedOnlyFieldListFilter` part is not a regression because it never
worked.

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:11>

Django

unread,
Aug 15, 2019, 7:14:48 AM8/15/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak <felisiak.mariusz@…>):

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


Comment:

In [changeset:"00035672a460b6eb5442d2837bc783f8af28c6f3" 00035672]:
{{{
#!CommitTicketReference repository=""
revision="00035672a460b6eb5442d2837bc783f8af28c6f3"
Fixed #30449 -- Fixed RelatedFieldListFilter/RelatedOnlyFieldListFilter to
respect model's Meta.ordering.

Regression in 6d4e5feb79f7eabe8a0c7c4b87f25b1a7f87ca0b.

Co-Authored-By: Mariusz Felisiak <felisiak...@gmail.com>
}}}

Django

unread,
Aug 15, 2019, 7:14:48 AM8/15/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"8289fc55fff879df273cb95fdd1b039447f85783" 8289fc55]:
{{{
#!CommitTicketReference repository=""
revision="8289fc55fff879df273cb95fdd1b039447f85783"
Refs #30449 -- Made RelatedOnlyFieldListFilter respect
ModelAdmin.ordering.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:12>

Django

unread,
Aug 15, 2019, 7:16:58 AM8/15/19
to django-...@googlegroups.com
#30449: Ordering problem in admin.RelatedFieldListFilter and
admin.RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: Moritz Pfeiffer | Owner: zeynel
Type: Bug | Status: closed
Component: contrib.admin | Version: master
Severity: Release blocker | Resolution: fixed
Keywords: | Triage Stage: Accepted
RelatedFieldListFilter, |
RelatedOnlyFieldListFilter, |
ordering |
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 1
-------------------------------------+-------------------------------------

Comment (by Mariusz Felisiak <felisiak.mariusz@…>):

In [changeset:"c2732e6839fffd96b136607f10af95fe58e0de17" c2732e6]:
{{{
#!CommitTicketReference repository=""
revision="c2732e6839fffd96b136607f10af95fe58e0de17"
[2.2.x] Fixed #30449 -- Fixed


RelatedFieldListFilter/RelatedOnlyFieldListFilter to respect model's
Meta.ordering.

Regression in 6d4e5feb79f7eabe8a0c7c4b87f25b1a7f87ca0b.

Co-Authored-By: Mariusz Felisiak <felisiak...@gmail.com>

Backport of 00035672a460b6eb5442d2837bc783f8af28c6f3 from master
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/30449#comment:13>

Reply all
Reply to author
Forward
0 new messages