Opened 13 hours ago
Last modified 12 hours ago
#36174 assigned New feature
Add "Show All" option when pagination is applied on the admin history page. — at Initial Version
Reported by: | Antoliny | Owned by: | |
---|---|---|---|
Component: | contrib.admin | Version: | 5.1 |
Severity: | Normal | Keywords: | pagination |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
In the admin change list page, pagination can be optionally applied through the list_per_page
option of ModelAdmin
.
class PostAdmin(admin.ModelAdmin): list_display = ["title"] list_per_page = 3 admin.site.register(Post, PostAdmin)
As shown in the image above, pagination related elements are rendered. Among them, a "Show all" button is provided, which allows users to view all objects when clicked.
In the admin History page, pagination is also applied automatically (not optionally) when the number of items exceeds 100, but the "Show all" option is not provided.
Since pagination is automatically applied in history_view, I believe history_view also needs a "Show all" button.
Additionally
I looked into why there are differences between the pagination applied in the history_view and the change_list. When the history_view was first implemented, this aspect was naturally considered, but I found that the pagination related template tags(pagination, pagination_number) only work with ChangeList
.
def pagination(cl): """ Generate the series of links to the pages in a paginated list. """ pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page page_range = cl.paginator.get_elided_page_range(cl.page_num) if pagination_required else [] need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page return { 'cl': cl, 'pagination_required': pagination_required, 'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}), 'page_range': page_range, 'ALL_VAR': ALL_VAR, '1': 1, }
I strongly feel that this issue should be resolved so that pagination is applied consistently across the Admin pages.
(I will create a separate issue regarding this matter.)