mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-03 20:10:10 +03:00
Merge c34b1e3db2
into 12394c9cac
This commit is contained in:
commit
216498f4f7
|
@ -133,6 +133,17 @@ class GenericAPIView(views.APIView):
|
||||||
# Determine the required page size.
|
# Determine the required page size.
|
||||||
# If pagination is not configured, simply return None.
|
# If pagination is not configured, simply return None.
|
||||||
page_size = self.get_paginate_by()
|
page_size = self.get_paginate_by()
|
||||||
|
if page_size == 0:
|
||||||
|
from django.core.paginator import Page
|
||||||
|
class Paginator():
|
||||||
|
def __init__(self, queryset):
|
||||||
|
self.count = queryset.count()
|
||||||
|
self.num_pages = 0
|
||||||
|
def validate_number(self, number):
|
||||||
|
return number
|
||||||
|
paginator = Paginator(queryset)
|
||||||
|
return Page(None, 0, paginator)
|
||||||
|
|
||||||
if not page_size:
|
if not page_size:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -218,6 +229,9 @@ class GenericAPIView(views.APIView):
|
||||||
|
|
||||||
if self.paginate_by_param:
|
if self.paginate_by_param:
|
||||||
try:
|
try:
|
||||||
|
if self.request.QUERY_PARAMS[self.paginate_by_param] == '0':
|
||||||
|
return 0
|
||||||
|
|
||||||
return strict_positive_int(
|
return strict_positive_int(
|
||||||
self.request.QUERY_PARAMS[self.paginate_by_param],
|
self.request.QUERY_PARAMS[self.paginate_by_param],
|
||||||
cutoff=self.max_paginate_by
|
cutoff=self.max_paginate_by
|
||||||
|
|
Loading…
Reference in New Issue
Block a user