mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-12-23 07:23:46 +00:00
Revert "Merge branch 'paginateur' into 'master'"
This reverts merge request !151
This commit is contained in:
parent
34d29349ed
commit
2d92799573
1 changed files with 10 additions and 14 deletions
|
@ -340,20 +340,16 @@ 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:
|
results = paginator.page(page)
|
||||||
results = paginator.page(page)
|
except PageNotAnInteger:
|
||||||
except PageNotAnInteger:
|
# If page is not an integer, deliver first page.
|
||||||
# If page is not an integer, deliver first page.
|
results = paginator.page(1)
|
||||||
results = paginator.page(1)
|
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