[Django] #25606: field_paths do not work in list_filter when using RelatedOnlyFieldListFilter

24 views
Skip to first unread message

Django

unread,
Oct 25, 2015, 10:42:45 AM10/25/15
to django-...@googlegroups.com
#25606: field_paths do not work in list_filter when using
RelatedOnlyFieldListFilter
-------------------------------+--------------------
Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 1
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Given this ModelAdmin:

{{{
class BookAdminRelatedOnlyFilter(admin.ModelAdmin):
list_filter = (
'edition__publisher',
('edition__publisher', RelatedOnlyFieldListFilter),
)
}}}


The first filter works fine, but the second results in a FieldError:
Cannot resolve keyword 'publisher' into field.

The reason this happens is because RelatedOnlyFieldListFilter uses
field.name instead of the field_path, where field is the result of
get_fields_from_path, which returns the 'publisher' field

This patch fixes this behaviour:
https://github.com/django/django/compare/master...quarkness:related-only-
filter-field-path
It also improves performance by using .distinct() on the database to get
unique values instead of set()

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

Django

unread,
Oct 26, 2015, 10:36:14 AM10/26/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------+------------------------------------

Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

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

* needs_better_patch: => 0
* needs_docs: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 1


Comment:

The [https://github.com/django/django/pull/5479 PR] from duplicate ticket
#25608 also lacks tests.

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

Django

unread,
Oct 27, 2015, 8:22:53 PM10/27/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------+------------------------------------
Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1
* needs_tests: 1 => 0


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

Django

unread,
Oct 29, 2015, 3:23:32 PM10/29/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------+------------------------------------
Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by jack-cvr):

* needs_better_patch: 1 => 0


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

Django

unread,
Oct 29, 2015, 4:52:37 PM10/29/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------+------------------------------------
Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

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

* needs_better_patch: 0 => 1


Comment:

Left some more comments and tests aren't passing.

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

Django

unread,
Oct 29, 2015, 11:03:17 PM10/29/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------+------------------------------------
Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
-------------------------------+------------------------------------
Changes (by jack-cvr):

* needs_better_patch: 1 => 0


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

Django

unread,
Nov 7, 2015, 11:12:03 AM11/7/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------

Reporter: quarkness | Owner: nobody
Type: Bug | Status: new
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution:
Keywords: | Triage Stage: Ready for
| checkin

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

* stage: Accepted => Ready for checkin


Comment:

Looks good.

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

Django

unread,
Nov 12, 2015, 7:51:32 PM11/12/15
to django-...@googlegroups.com
#25606: Add support for "__" lookup in RelatedOnlyFieldListFilter
-------------------------------------+-------------------------------------
Reporter: quarkness | Owner: nobody
Type: Bug | Status: closed
Component: contrib.admin | Version: 1.8
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Tim Graham <timograham@…>):

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


Comment:

In [changeset:"815f4d206dfea41bdff167283c2cac43a71524ac" 815f4d2]:
{{{
#!CommitTicketReference repository=""
revision="815f4d206dfea41bdff167283c2cac43a71524ac"
Fixed #25606 -- Added support for "__" lookup in RelatedOnlyFieldList
}}}

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

Reply all
Reply to author
Forward
0 new messages