How can I get count of pages in LimitOffsetPagination django rest framework?

If my code looks like this:

class SimpleLimitOffsetPagination(LimitOffsetPagination):

    offset_query_param = 'page'
    max_limit = 100
    default_limit = 5

    def get_paginated_response(self, data):
        return Response({
            'count': self.count,
            'max_page': 'needs count of pages',
            'results': data
        })     

Is that possible to get count of pages? or do we have another solution? It's important to have an opportunity using limit filed.

Using a limit/offset is usefull when you don't want to worry about pages and have a more flexible way to retrieve a certain number of rows.
In your case, you'd better stick to a standard PageNumberPagination.

Back to Top