Opened 5 years ago

Closed 5 years ago

#29919 closed Bug (fixed)

Using RelatedOnlyFieldListFilter with reverse ManyToMany crashes

Reported by: Dan Moore Owned by: nobody
Component: contrib.admin Version: 2.1
Severity: Normal Keywords:
Cc: Collin Anderson Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Tim Graham)

Using RelatedOnlyFieldListFilter with a reverse ManyToMany relation causes this exception:

get_choices() got an unexpected keyword argument 'limit_choices_to'

This method in ForeignObjectRel.get_choices is missing the parameter that Field.get_choices has.

Pull Request: https://github.com/django/django/pull/10606

Demo of how to trigger bug: https://github.com/mgrdcm/django-bug-reverse-related/blob/master/rrbug/rrapp/admin.py#L11-L15

Change History (10)

comment:1 by Dan Moore, 5 years ago

Description: modified (diff)

comment:2 by Tim Graham, 5 years ago

I can't reproduce the crash on a ManyToManyField with limit_choices_to. Could you give more details?

comment:3 by Dan Moore, 5 years ago

Description: modified (diff)

Apologies for my lack of response on this, have been traveling. I'm going to be working on adding tests for my fix ASAP but here's a minimal example of how to trigger: Demo of how to trigger bug: https://github.com/mgrdcm/django-bug-reverse-related/blob/master/rrbug/rrapp/admin.py#L11-L15

comment:5 by Tim Graham, 5 years ago

Description: modified (diff)
Summary: Using RelatedOnlyFieldListFilter with ManyToMany causes exceptionUsing RelatedOnlyFieldListFilter with reverse ManyToMany crashes
Triage Stage: UnreviewedAccepted

comment:6 by Tim Graham, 5 years ago

Patch needs improvement: set

comment:7 by Tim Graham, 5 years ago

Patch needs improvement: unset

comment:8 by Collin Anderson, 5 years ago

Cc: Collin Anderson added
Needs tests: set
Patch needs improvement: set

Tim says "test should very the correct results of the Filter rather than just checking that an exception isn't raised."

comment:9 by Tim Graham, 5 years ago

Needs tests: unset
Patch needs improvement: unset

comment:10 by Mariusz Felisiak <felisiak.mariusz@…>, 5 years ago

Resolution: fixed
Status: newclosed

In bc94e3c:

Fixed #29919 -- Fixed RelatedOnlyFieldListFilter crash with reverse relationships.

Note: See TracTickets for help on using tickets.
Back to Top