#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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/010701886b8dd414-dc531910-7af4-47ce-86d3-6f912d665bca-000000%40eu-central-1.amazonses.com.

Reply via email to