1

I'm using pagination in Django 1.11. But when I use has_next and has_previous it returns false everytime. Don't print anything. I'm sure that there is previous and next pages. In views I'm using TableView which is like ListView. Here is my code:

<div class="pagination">
        <span class="step-links">

          {% if customers.has_next %}
            <p>HAS NEXT</p>
          {% endif %}
          {% if customers.has_previous %}
            <p>HAS PREVİOUS</p>
          {% endif %}




        </span>
      </div>

views.py

class TableView(ExportMixin, SingleTableView):
    model = Customer
    table_class = CustomerTable
    template_name = 'admin_pages/user_admin_page.html'
    context_object_name = 'customers'
    paginate_by = 3

*I'm using tableview just for export table.

Sunderam Dubey
  • 1
  • 11
  • 20
  • 40

1 Answers1

1

You should work with the page_obj object, so:

{% if page_obj.has_next %}
  <p>HAS NEXT</p>
{% endif %}
{% if page_obj.has_previous %}
  <p>HAS PREVİOUS</p>
{% endif %}
Willem Van Onsem
  • 443,496
  • 30
  • 428
  • 555