7👍
✅
my_view.py
class BienAgence(generics.ListAPIView):
queryset = FacebookBien.objects
pagination_class = SmallPagesPagination
def get(self, request, *args, **kwargs):
...
serializer = FacebookBienSerializer(toto, many=True)
page = self.paginate_queryset(serializer.data)
return self.get_paginated_response(page)
-1👍
One way is to override the MyOffsetPagination class
like this
from rest_framework.pagination import LimitOffsetPagination
class MyOffsetPagination(LimitOffsetPagination):
default_limit = 20
max_limit = 1000
and then add this in your view
pagination_class = MyOffsetPagination
Don’t forget to add this in you settings
'DEFAULT_PAGINATION_CLASS': (
'rest_framework.pagination.PageNumberPagination'),
'PAGE_SIZE': (50)
- [Django]-How to get last login ip in django and save to a GenericIPAddressField?
- [Django]-Django.core.exceptions.FieldError: Cannot resolve keyword 'timestamp' into field
- [Django]-Django sequence:item 4 expected string or unicode int found
Source:stackexchange.com