[Django] #34605: Add distinct support for ListFilters

7 views
Skip to first unread message

Django

unread,
May 30, 2023, 3:27:21 AM5/30/23
to django-...@googlegroups.com
#34605: Add distinct support for ListFilters
-------------------------------------------+------------------------
Reporter: Karolis Ryselis | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 4.2
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------------+------------------------
Current implementation of {{{ChangeList.get_filters()}}} returns
may_have_duplicates, which only accounts for field list filters, but not
custom list filters where no field is used. One possibility is to add
{{{.distinct()}}} in the {{{queryset()}}} method of the filter, but it
prevents the objects to be deleted using changelist because
{{{.delete()}}} cannot be called after {{{.distinct()}}}. Another approach
is to use the approach from {{{ChangeList.get_queryset()}}} - subquery +
{{{Exists()}}} in filter's queryset, however, this adds unnecessary
complexity on the query if multiple such filters are applied or other
filters/search may have duplicates - it would then nest the subqueries,
which is suboptimal.

I am not sure about the best solution for this - maybe add method
may_have_duplicates on filter spec classes, which defaults to current
{{{lookup_needs_distinct}}} call for field filters and raises
{{{NotImplementedError}}} for the others?

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

Django

unread,
May 30, 2023, 3:27:34 AM5/30/23
to django-...@googlegroups.com
#34605: Add distinct support for ListFilters
-------------------------------------+-------------------------------------

Reporter: Karolis Ryselis | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: Uncategorized | Version: 4.2
Severity: Normal | Resolution:

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Karolis Ryselis):

* type: Uncategorized => Cleanup/optimization


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

Django

unread,
May 30, 2023, 3:00:19 PM5/30/23
to django-...@googlegroups.com
#34605: Add distinct support for ListFilters
-------------------------------------+-------------------------------------
Reporter: Karolis Ryselis | Owner: nobody
Type: | Status: new
Cleanup/optimization |
Component: contrib.admin | Version: 4.2

Severity: Normal | Resolution:
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

* component: Uncategorized => contrib.admin


Comment:

Hello, thank you for your report.

Could you please provide a minimal django app showcasing the issue? That
will help us further triage this report.Thank you!

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

Django

unread,
May 31, 2023, 1:41:13 PM5/31/23
to django-...@googlegroups.com
#34605: Add distinct support for ListFilters
-------------------------------------+-------------------------------------
Reporter: Karolis Ryselis | Owner: nobody
Type: | Status: closed

Cleanup/optimization |
Component: contrib.admin | Version: 4.2
Severity: Normal | Resolution: needsinfo

Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Natalia Bidart):

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


Comment:

Forgot to close as needsinfo, but I'm happy to reopen when more
information is provided. Thanks!

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

Reply all
Reply to author
Forward
0 new messages