{% if page_obj.has_other_pages %}
<div class="flex justify-center mt-6">
  <div class="join">

    {% if page_obj.has_previous %}
      <a href="?page={{ page_obj.previous_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.status %}&status={{ request.GET.status }}{% endif %}{% if request.GET.branch %}&branch={{ request.GET.branch }}{% endif %}"
         class="join-item btn btn-sm">«</a>
    {% else %}
      <button class="join-item btn btn-sm btn-disabled">«</button>
    {% endif %}

    {% for num in page_obj.paginator.page_range %}
      {% if page_obj.number == num %}
        <button class="join-item btn btn-sm btn-active">{{ num }}</button>
      {% elif num > page_obj.number|add:'-3' and num < page_obj.number|add:'3' %}
        <a href="?page={{ num }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.status %}&status={{ request.GET.status }}{% endif %}{% if request.GET.branch %}&branch={{ request.GET.branch }}{% endif %}"
           class="join-item btn btn-sm">{{ num }}</a>
      {% endif %}
    {% endfor %}

    {% if page_obj.has_next %}
      <a href="?page={{ page_obj.next_page_number }}{% if request.GET.q %}&q={{ request.GET.q }}{% endif %}{% if request.GET.status %}&status={{ request.GET.status }}{% endif %}{% if request.GET.branch %}&branch={{ request.GET.branch }}{% endif %}"
         class="join-item btn btn-sm">»</a>
    {% else %}
      <button class="join-item btn btn-sm btn-disabled">»</button>
    {% endif %}

  </div>
</div>
{% endif %}
