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

已查看 27 次
跳至第一个未读帖子

Django

未读,
2019年5月6日 10:04:162019/5/6
收件人 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

未读,
2019年5月6日 10:07:212019/5/6
收件人 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

未读,
2019年5月6日 10:09:382019/5/6
收件人 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

未读,
2019年5月9日 05:13:182019/5/9
收件人 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

未读,
2019年5月12日 02:42:172019/5/12
收件人 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

未读,
2019年5月13日 02:20:532019/5/13
收件人 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

未读,
2019年6月12日 10:00:362019/6/12
收件人 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

未读,
2019年7月20日 09:01:552019/7/20
收件人 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

未读,
2019年7月20日 09:08:032019/7/20
收件人 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

未读,
2019年8月12日 11:40:182019/8/12
收件人 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

未读,
2019年8月12日 11:41:252019/8/12
收件人 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

未读,
2019年8月14日 08:30:382019/8/14
收件人 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

未读,
2019年8月14日 09:04:422019/8/14
收件人 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

未读,
2019年8月15日 01:31:572019/8/15
收件人 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

未读,
2019年8月15日 07:14:482019/8/15
收件人 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

未读,
2019年8月15日 07:14:482019/8/15
收件人 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

未读,
2019年8月15日 07:16:582019/8/15
收件人 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>

回复全部
回复作者
转发
0 个新帖子