Skip to content
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

Pagination with Page Numbers #1463

Merged
merged 1 commit into from
Oct 6, 2023
Merged
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
41 changes: 30 additions & 11 deletions website/templates/list_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,24 @@ <h1 class="page-header">All {% if label %}{{ label }}{% endif %} issues{% if use
<div class="col-md-12">
<div class="text-center">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}"
class="btn btn-default">Prev</a>
<a href="?page=1{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}"
class="btn btn-default">First</a>
{% else %}
<button class="btn btn-default" disabled>First</button>
{% endif %}
<span>Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
{% for num in page_obj.paginator.page_range %}
{% if num == page_obj.number %}
<button class="btn btn-default" disabled>{{num}}</button>
{% elif num > page_obj.number|add:"-5" and num < page_obj.number|add:"5" %}
<a href="?page={{ num }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}" class="btn btn-default">{{num}}</a>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}"
class="btn btn-default">Next</a>
<a href="?page={{ page_obj.paginator.num_pages }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}" class="btn btn-default">Last</a>
{% else %}
<button class="btn btn-default" disabled>Last</button>
{% endif %}
<div>Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</div>
</div>
</div>
{% endif %}
Expand All @@ -38,17 +48,26 @@ <h1 class="page-header">All {% if label %}{{ label }}{% endif %} issues{% if use
<div class="col-md-12">
<div class="text-center">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}"
class="btn btn-default">Prev</a>
<a href="?page=1{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}" class="btn btn-default">First</a>
{% else %}
<button class="btn btn-default" disabled>First</button>
{% endif %}
<span>Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</span>
{% for num in page_obj.paginator.page_range %}
{% if num == page_obj.number %}
<button class="btn btn-default" disabled>{{num}}</button>
{% elif num > page_obj.number|add:"-5" and num < page_obj.number|add:"5" %}
<a href="?page={{ num }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}" class="btn btn-default">{{num}}</a>
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}"
class="btn btn-default">Next</a>
<a href="?page={{ page_obj.paginator.num_pages }}{% if user %}&user={{ user }}{% endif %}{% if label %}&label={{ label }}{% endif %}" class="btn btn-default">Last</a>
{% else %}
<button class="btn btn-default" disabled>Last</button>
{% endif %}
<div>Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}</div>
</div>
</div>
{% endif %}
<br><br>
</div>
{% endblock %}
{% endblock %}
Loading