1 | | In the admin change list page, pagination can be optionally applied through the `list_per_page` option of `ModelAdmin`. |
| 1 | Currently, pagination in history_view is applied automatically (when EntryObjects exceed 100). |
| 2 | [[Image(history_view_pagination.png)]] |
| 3 | {{{ |
| 4 | def history_view(...): |
| 5 | paginator = self.get_paginator(request, action_list, 100) |
| 6 | page_number = request.GET.get(PAGE_VAR, 1) |
| 7 | page_obj = paginator.get_page(page_number) |
| 8 | page_range = paginator.get_elided_page_range(page_obj.number) |
| 9 | |
| 10 | context = { |
| 11 | **self.admin_site.each_context(request), |
| 12 | "title": _("Change history: %s") % obj, |
| 13 | "subtitle": None, |
| 14 | "action_list": page_obj, |
| 15 | "page_range": page_range, |
| 16 | "page_var": PAGE_VAR, |
| 17 | "pagination_required": paginator.count > 100, |
| 18 | }}} |
| 19 | As shown in the code above, the pagination value(100) is static, and I would like it to be optionally provided, similar to how pagination is applied in `list_display`. |
9 | | [[Image(change_list_pagination.png)]] |
10 | | 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. |
11 | | |
12 | | 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. |
13 | | [[Image(history_view_pagination.png)]] |
14 | | |
15 | | Since pagination is automatically applied in history_view, I believe history_view also needs a "Show all" button. |
16 | | |
17 | | === Additionally === |
18 | | |
19 | | 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`. |
20 | | {{{ |
21 | | def pagination(cl): |
22 | | """ |
23 | | Generate the series of links to the pages in a paginated list. |
24 | | """ |
25 | | pagination_required = (not cl.show_all or not cl.can_show_all) and cl.multi_page |
26 | | page_range = cl.paginator.get_elided_page_range(cl.page_num) if pagination_required else [] |
27 | | need_show_all_link = cl.can_show_all and not cl.show_all and cl.multi_page |
28 | | return { |
29 | | 'cl': cl, |
30 | | 'pagination_required': pagination_required, |
31 | | 'show_all_url': need_show_all_link and cl.get_query_string({ALL_VAR: ''}), |
32 | | 'page_range': page_range, |
33 | | 'ALL_VAR': ALL_VAR, |
34 | | '1': 1, |
35 | | } |
36 | | }}} |
37 | | I strongly feel that this issue should be resolved so that pagination is applied consistently across the Admin pages. |
38 | | (I will create a separate issue regarding this matter.) |
| 26 | Moreover, since the "Show all" button available in list_display is not provided in history_view, this need feels even more necessary. |
| 27 | (Even if the "Show all" button is not provided, I believe this functionality is still necessary. It is especially useful when searching for a specific object using text(Ex.. Mac Command + F) search or similar features when pagination is not applied.) |