{% if is_paginated %}
    <nav aria-label="Page navigation example">
        <ul class="pagination">
            {% if page_obj.has_previous %}
            <li class="page-item">
                <a href="?page=1" class="page-link" title="First Page" aria-label="First">
                    First
                </a>
            </li>

            
            <li class="page-item">
                <a href="?page={{page_obj.previous_page_number}}" class="page-link" aria-label="Previous">
                    Prev
                </a>
            </li>
            {% endif %}

            
            {% for num in page_obj.paginator.page_range %}
                {% if page_obj.number == num %}
                    <li class="page-item active">
                        <a class="page-link">{{num}}</a>
                    </li>
                    {% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
                    <li class="page-item">
                        <a href="?page={{ num }}" class="page-link">{{num}}</a>
                    </li>
                {% endif %}
            {% endfor %}

            {% if page_obj.has_next %}
            <li class="page-item">
                <a href="?page={{page_obj.next_page_number}}" class="page-link" aria-label="Next">
                    Next
                </a>
            </li>
            <li class="page-item">
                <a href="?page={{page_obj.paginator.num_pages}}" class="page-link" aria-label="Last">
                    Last
                </a>
            </li>
            {% endif %}
        </ul>
    </nav>
{% endif %}