﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
33404	Make `get_elided_page_range` easier to use	Michael		"The `paginator.get_elided_page_range` is an awesome function, the only problem is it's very hard to call correctly.

It requires the current page number in order to render range range correctly. Without the page number it always renders as if you are on page one.

This means when one tries to use it in the template like this:
{{{
    {% for i in paginator.get_elided_page_range %}
        ...
    {% endfor %}
}}}
It renders only correctly when one is on page one, because the `paginator` does not know the current page.
I stumbled across this [https://stackoverflow.com/questions/69277936/how-to-use-get-elided-page-range-in-django-paginator stackoverflow question] that someone else posted.

However the `page_obj` knows the current page number (`self.number`), and it has `self.paginator`. It's quite trivial to just delegate the call.

In file `django.core.paginator.py` at the very bottom just add this to `class Page`:
{{{
    def get_elided_page_range(self, *args, **kwargs):
        return self.paginator.get_elided_page_range(self.number, *args, **kwargs)
}}}

Then in the template one can simply do:
{{{
    {% for i in page_obj.get_elided_page_range %}
        ...
    {% endfor %}
}}}
And everything works as expected.

If the general consenseus is this is a good thing, and I am not missing something that already fixes this problem, I can try create a patch and update the documentation.

And heres a more complete example usage:
{{{
    {% for i in page_obj.get_elided_page_range %}
        {% if i == page_obj.number %}
            <div>{{ i }}</div>
        {% elif i == paginator.ELLIPSIS %}
            <div>{{ i }}</div>
        {% else %}
            <a  href=""{% paginator_url i %}"">{{ i }}</a>
        {% endif %}
    {% endfor %}
}}}
"	New feature	closed	Template system	4.0	Normal	invalid	pagination paginator page_obj		Accepted	0	1	0	0	1	0
