Opened 23 months ago

Closed 6 months ago

#22810 closed Bug (fixed)

full_result_count optimization is wrong in the presence of custom ListFilters

Reported by: gwahl@… Owned by: nobody
Component: contrib.admin Version: 1.6
Severity: Normal Keywords:
Cc: Triage Stage: Accepted
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

ChangeList.get_results performs an optimization when counting the total number of results, disregarding list filters. It assumes that if there are no query parameters, the full count is the same as the filtered count. This is incorrect when a custom list filter does filtering when there are no query parameters.

In my case, the list filter filters the objects by default, and removes the filtering with a query parameter. The optimization incorrectly assumes that there is no filtering by default, so the total result count is wrong.

https://github.com/django/django/blob/master/django/contrib/admin/views/main.py#L172, see 'Perform a slight optimization'.

Change History (4)

comment:1 Changed 23 months ago by timo

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Triage Stage changed from Unreviewed to Accepted
  • Type changed from Uncategorized to Bug

comment:3 Changed 6 months ago by slurms

  • Has patch set

comment:4 Changed 6 months ago by Tim Graham <timograham@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 5fa7b59:

Fixed #22810 -- Corrected admin changelist count for list filters that filter by default.

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