{% load url_replace %}
<nav id="page-selector" aria-label="Page navigation">
  <ul class="pagination justify-content-center">
    {% if page_obj.has_previous %}
      <li class="page-item">
        <a class="page-link" href="?{% url_replace request 'page' page_obj.previous_page_number %}" aria-label="Previous">
            <span aria-hidden="true">&laquo;</span>
        </a>
      </li>
    {% else %}
      <li class="page-item disabled">
        <a class="page-link" href="#" aria-label="Previous" aria-disabled>
            <span aria-hidden="true">&laquo;</span>
        </a>
      </li>
    {% endif %}

    {% if show_first %}
      <li class="page-item">
        <a class="page-link" href="?{% url_replace request 'page' 1 %}">1</a>
      </li>
      <li class="page-item">
        <a class="page-link" href="#">...</a>
      </li>
    {% endif %}

    {% for page in page_numbers %}
      {% if page == page_obj.number %}
        <li class="page-item active" aria-current="page">
          <a class="page-link" href="?{% url_replace request 'page' page %}">{{ page }}</a>
        </li>
      {% else %}
        <li class="page-item">
          <a class="page-link" href="?{% url_replace request 'page' page %}">{{ page }}</a>
        </li>
      {% endif %}
    {% endfor %}

    {% if show_last %}
      <li class="page-item">
        <a class="page-link" href="#">...</a>
      </li>
      <li class="page-item">
        <a class="page-link" href="?{% url_replace request 'page' 'last' %}">{{ paginator.num_pages }}</a>
      </li>
    {% endif %}

    {% if page_obj.has_next %}
      <li class="page-item">
        <a class="page-link" href="?{% url_replace request 'page' page_obj.next_page_number %}" aria-label="Next">
            <span aria-hidden="true">&raquo;</span>
        </a>
      </li>
    {% else %}
      <li class="page-item disabled">
        <a class="page-link" href="#" aria-label="Next" aria-disabled>
            <span aria-hidden="true">&raquo;</span>
        </a>
      </li>
    {% endif %}
  </ul>
</nav>
