Opened 14 years ago

Closed 13 years ago

Last modified 13 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: no UI/UX: no

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 Matthias Kestenholz 14 years ago.
12893_modeladmin_pagination_tests.diff (2.3 KB ) - added by Julien Phalip 13 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Russell Keith-Magee, 14 years ago

Triage Stage: UnreviewedAccepted

comment:2 by Matthias Kestenholz, 14 years ago

Has patch: set

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

by Matthias Kestenholz, 14 years ago

Attachment: test12893.patch added

by Julien Phalip, 13 years ago

comment:3 by Julien Phalip, 13 years ago

Triage Stage: AcceptedReady 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 by Russell Keith-Magee, 13 years ago

Resolution: fixed
Status: newclosed

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 by Russell Keith-Magee, 13 years ago

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