{% load url_replace %}
<nav>
  <ul class="pagination">
    {% if page_obj.has_previous %}
      <li>
        <a href="?{% url_replace request 'page' page_obj.previous_page_number %}">&laquo;</a>
      </li>
    {% else %}
      <li class="disabled">
        <a href="#"><span>&laquo;</span></a>
      </li>
    {% endif %}

    {% if show_first %}
      <li>
        <a href="?{% url_replace request 'page' 1 %}">1</a>
      </li>
      <li>
        <span>...</span>
      </li>
    {% endif %}

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

    {% if show_last %}
      <li>
        <span>...</span>
      </li>
      <li>
        <a href="?{% url_replace request 'page' 'last' %}">{{ paginator.num_pages }}</a>
      </li>
    {% endif %}

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