{% load viewset_tags i18n %}{% spaceless %}

{% if is_paginated %}
  <nav>
    <ul class="pagination mb-0">
      {% if page_obj.has_previous %}
        <li class="page-item">
          <a class="page-link" href="?{% url_replace page=1 %}">&laquo;</a>
        </li>
        <li class="page-item">
          <a class="page-link" href="?{% url_replace page=page_obj.previous_page_number %}">&lsaquo;</a>
        </li>
      {% else %}
        <li class="page-item disabled">
          <span class="page-link">&laquo;</span>
        </li>
        <li class="page-item disabled">
          <span class="page-link">&lsaquo;</span>
        </li>
      {% endif %}

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

      {% if page_obj.has_next %}
        <li class="page-item">
          <a class="page-link" href="?{% url_replace page=page_obj.next_page_number %}">&rsaquo;</a>
        </li>
        <li class="page-item">
          <a class="page-link" href="?{% url_replace page=paginator.num_pages %}">&raquo;</a>
        </li>
      {% else %}
        <li class="page-item disabled">
          <span class="page-link">&rsaquo;</span>
        </li>
        <li class="page-item disabled">
          <span class="page-link">&raquo;</span>
        </li>
      {% endif %}
    </ul>
  </nav>
{% endif %}
{% endspaceless %}