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:1 by , 7 years ago
comment:2 by , 7 years ago
Summary: | ChangeList instantiation code buried in ModelAdmin.changelist_view is not reusable → Add ModelAdmin.get_changelist_instance() |
---|---|
Triage Stage: | Unreviewed → Ready for checkin |
https://github.com/django/django/pull/8903