{% load paginator_tags %}

<head>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css">
</head>
<body>

  <ul class="pagination {% size %}">

    {% if page_obj.has_previous %}
      <li class="page-item">
        <a class="page-link" href="?{% url_replace 'page' page_obj.previous_page_number %}">&laquo;</a>
      </li>
    {% else %}
      <li class="page-item disabled">
        <a class="page-link" href="#">&laquo;</a>
      </li>
    {% endif %}

  {% for page_num in page_obj.paginator.page_range %}
    {% ellipsis_or_number page_obj.paginator page_num as answer %}
    {% if answer != None %}
    <li class="page-item {% if page_obj.number == page_num %}active{% endif %}">
        <a class="page-link active" href="?{% url_replace 'page' page_num %}">{{ answer }}</a>
      </li>
    {% endif %}
  {% endfor %}

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

  </ul>
</body>
