mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-05 01:16:27 +00:00
Fix #111 properly
This commit is contained in:
parent
dcd1e2af96
commit
8c2b2ca8df
2 changed files with 13 additions and 16 deletions
|
@ -340,7 +340,6 @@ def re2o_paginator(request, query_set, pagination_number):
|
||||||
:request:
|
:request:
|
||||||
:query_set: Query_set to paginate
|
:query_set: Query_set to paginate
|
||||||
:pagination_number: Number of entries to display"""
|
:pagination_number: Number of entries to display"""
|
||||||
if query_set.count() > pagination_number:
|
|
||||||
paginator = Paginator(query_set, pagination_number)
|
paginator = Paginator(query_set, pagination_number)
|
||||||
page = request.GET.get('page')
|
page = request.GET.get('page')
|
||||||
try:
|
try:
|
||||||
|
@ -351,9 +350,6 @@ def re2o_paginator(request, query_set, pagination_number):
|
||||||
except EmptyPage:
|
except EmptyPage:
|
||||||
# If page is out of range (e.g. 9999), deliver last page of results.
|
# If page is out of range (e.g. 9999), deliver last page of results.
|
||||||
results = paginator.page(paginator.num_pages)
|
results = paginator.page(paginator.num_pages)
|
||||||
else:
|
|
||||||
#If there is only one page, deliver the page without paginator
|
|
||||||
return query_set
|
|
||||||
return results
|
return results
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
|
|
||||||
{% load url_insert_param %}
|
{% load url_insert_param %}
|
||||||
|
|
||||||
|
{% if list.paginator.num_pages > 1 %}
|
||||||
<ul class="pagination nav navbar-nav">
|
<ul class="pagination nav navbar-nav">
|
||||||
{% if list.has_previous %}
|
{% if list.has_previous %}
|
||||||
<li><a href="{% url_insert_param request.get_full_path page=1 %}"> << </a></li>
|
<li><a href="{% url_insert_param request.get_full_path page=1 %}"> << </a></li>
|
||||||
|
@ -40,4 +41,4 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||||
<li><a href="{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}"> >> </a></li>
|
<li><a href="{% url_insert_param request.get_full_path page=list.paginator.page_range|length %}"> >> </a></li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</ul>
|
</ul>
|
||||||
|
{% endif %}
|
||||||
|
|
Loading…
Reference in a new issue