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.
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 %}
Note: django-1.11 is no longer supported [Django-doc] since April 2020, you should consider upgrading the Django version.