mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-16 00:13:12 +00:00
Fixe #111: Supression du paginateur si page unique
This commit is contained in:
parent
c2facd8a27
commit
5575995437
1 changed files with 14 additions and 10 deletions
|
@ -297,6 +297,7 @@ 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:
|
||||||
|
@ -307,6 +308,9 @@ 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
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue