{{{
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.
* 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>
* needs_better_patch: 0 => 1
* needs_tests: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25606#comment:2>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25606#comment:3>
* 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>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25606#comment:5>
* stage: Accepted => Ready for checkin
Comment:
Looks good.
--
Ticket URL: <https://code.djangoproject.com/ticket/25606#comment:6>
* 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>