Opened 5 years ago

Closed 4 years ago

Last modified 4 years ago

#12893 closed (fixed)

Pagination in admins changelist doesn't use queryset set by modeladmin

Reported by: Willian Owned by: nobody
Component: contrib.admin Version: 1.2-alpha
Severity: Keywords:
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

When the queryset method in a ModelAdmin gets overwriten (to for example filter some records out) the changelist uses the given queryset, but the pagination counts all records including the ones that filtered out by the get_queryset.

Attachments (2)

test12893.patch (1.8 KB) - added by mk 4 years ago.
12893_modeladmin_pagination_tests.diff (2.3 KB) - added by julien 4 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 5 years ago by russellm

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

comment:2 Changed 4 years ago by mk

  • Has patch set

I cannot reproduce this problem, neither on 1.2 nor on current trunk. Unittest attached.

Changed 4 years ago by mk

Changed 4 years ago by julien

comment:3 Changed 4 years ago by julien

  • Triage Stage changed from Accepted to Ready for checkin

I confirm that everything works fine, but it doesn't hurt adding more regression tests so thank you mk for your patch. I've just updated it by explicitly using list_per_page, reducing the number of created objects (anything we can do to speed up the test suite :-) ), and writing tests for when the default queryset is used.

comment:4 Changed 4 years ago by russellm

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

In [15578]:

Fixed #12893 -- Added tests to validate that the right queryset is always used in model admins. Thanks to mk and Julien Phalip for their work on the patch.

comment:5 Changed 4 years ago by russellm

In [15579]:

[1.2.X] Fixed #12893 -- Added tests to validate that the right queryset is always used in model admins. Thanks to mk and Julien Phalip for their work on the patch.

Backport of r15578 from trunk.

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