Opened 7 years ago

Closed 7 years ago

#28496 closed Cleanup/optimization (fixed)

Add ModelAdmin.get_changelist_instance()

Reported by: Simon Meers Owned by: Simon Meers
Component: contrib.admin Version: 1.11
Severity: Normal 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

As requested/discussed in https://github.com/django/django/pull/8856

It is sometimes necessary to access the filtered/searched QuerySet generated by the current request parameters outside of the changelist_view. For example, when exporting the current queryset in a custom view. In the current implementation, this cannot be achieved in a DRY fashion. Extracting the ChangeList instantiation into its own method allows this DRY reuse.

This also allows the test code to utilise consistent/DRY instantiation of ChangeList objects in place of the current hacks such as admin_changelist.tests.get_changelist_args -- see new pull request.

Change History (3)

comment:2 by Tim Graham, 7 years ago

Summary: ChangeList instantiation code buried in ModelAdmin.changelist_view is not reusableAdd ModelAdmin.get_changelist_instance()
Triage Stage: UnreviewedReady for checkin

comment:3 by Tim Graham <timograham@…>, 7 years ago

Resolution: fixed
Status: assignedclosed

In 7bba824:

Fixed #28496 -- Added ModelAdmin.get_changelist_instance().

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