Skip to content

fix: add pagination classes to nav section #866

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions django_tables2/templates/django_tables2/bootstrap.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,24 +58,22 @@
{% if table.page and table.paginator.num_pages > 1 %}
<nav aria-label="Table navigation">
<ul class="pagination">
{% if table.page.has_previous %}
{% block pagination.previous %}
<li class="previous">
<a href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}">
<li class="page-item previous{% if not table.page.has_previous %} disabled{% endif %}">
<a class="page-link" {% if table.page.has_previous %}href="{% querystring table.prefixed_page_field=table.page.previous_page_number %}"{% endif %}>
<span aria-hidden="true">&laquo;</span>
{% trans 'previous' %}
</a>
</li>
{% endblock pagination.previous %}
{% endif %}
{% if table.page.has_previous or table.page.has_next %}
{% block pagination.range %}
{% for p in table.page|table_page_range:table.paginator %}
<li {% if p == table.page.number %}class="active"{% endif %}>
<li class="page-item{% if p == table.page.number %} active{% endif %}">
{% if p == '...' %}
<a href="#">{{ p }}</a>
<a class="page-link" href="#">{{ p }}</a>
{% else %}
<a href="{% querystring table.prefixed_page_field=p %}">
<a class="page-link" href="{% querystring table.prefixed_page_field=p %}">
{{ p }}
</a>
{% endif %}
Expand All @@ -84,16 +82,14 @@
{% endblock pagination.range %}
{% endif %}

{% if table.page.has_next %}
{% block pagination.next %}
<li class="next">
<a href="{% querystring table.prefixed_page_field=table.page.next_page_number %}">
{% block pagination.next %}
<li class="next page-item{% if not table.page.has_next %} disabled{% endif %}">
<a class="page-link" {% if table.page.has_next %}href="{% querystring table.prefixed_page_field=table.page.next_page_number %}"{% endif %}>
{% trans 'next' %}
<span aria-hidden="true">&raquo;</span>
</a>
</li>
{% endblock pagination.next %}
{% endif %}
</ul>
</nav>
{% endif %}
Expand Down