[Django] #33144: 'get_elided_page_range' method doesn't work properly

85 views
Skip to first unread message

Django

unread,
Sep 25, 2021, 6:37:20 PM9/25/21
to django-...@googlegroups.com
#33144: 'get_elided_page_range' method doesn't work properly
-------------------------------------+-------------------------------------
Reporter: axinterop | Owner: nobody
Type: Bug | Status: new
Component: Generic | Version: 3.2
views | Keywords: paginator,
Severity: Normal | pagination, get_elided_page_range,
Triage Stage: | ListView
Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
I found that the page number is not passed to the
''get_elided_page_range'' method and it uses the default value (1) all the
time.

Having, for example, 34 pages, ''get_elided_page_range'' will always
return ''1 2 3 4 … 33 34'' range **regardless** of the current page
number.

**views.py**
{{{
class TopicListView(ListView):
model = Topic
context_object_name = 'topics'
template_name = 'topics.html'
paginate_by = 3

def get_context_data(self, *, object_list=None, **kwargs):
context = super().get_context_data(**kwargs)
context['board'] = self.board
return context

def get_queryset(self):
self.board = get_object_or_404(Board,
id=self.kwargs.get('board_id'))
queryset = self.board.topics.order_by('last_updated').\
annotate(replies=Count('posts') - 1)
return queryset
}}}

**topics.html**
{{{
...
{% for page_num in paginator.get_elided_page_range %}
{{ page_num }}
{% endfor %}
...
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/33144>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 27, 2021, 12:13:29 AM9/27/21
to django-...@googlegroups.com
#33144: get_elided_page_range() method doesn't work properly.

-------------------------------------+-------------------------------------
Reporter: axinterop | Owner: nobody
Type: Bug | Status: closed
Component: Generic views | Version: 3.2
Severity: Normal | Resolution: invalid
Keywords: paginator, | Triage Stage:
pagination, | Unreviewed
get_elided_page_range, ListView |

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => invalid


Comment:

Thanks for the report, however it's an issue in your code not in Django
itself. `get_elided_page_range()` is a method not an attribute, and
shouldn't be called directly on templates. You can check how it's used in
admin, see
[https://github.com/django/django/blob/8036b53de61f16098a2f22c50621987182bdfaed/django/contrib/admin/templatetags/admin_list.py#L47-L61
pagination()]. If you're having trouble understanding how Django works,
see TicketClosingReasons/UseSupportChannels for ways to get help

--
Ticket URL: <https://code.djangoproject.com/ticket/33144#comment:1>

Reply all
Reply to author
Forward
0 new messages