Skip to main content

response pagination using django restframework

Project description

example:

class TestAPI(APIView):

    @staticmethod
    def get(request):
        tests = Test.objects.all() # filter or order by or anything else
        
        pagination = PaginationObject(objects=tests, page=1, numbers_in_page=10, 
                     serializer=TestSerializer)

        return Response(pagination.serializer_data(), status=status.HTTP_200_OK)

to get all objects in one page :

        pagination = PaginationObject(objects=tests, page=1, numbers_in_page=-1, 
                     serializer=TestSerializer)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

djangorestframework_pagination-1.2.tar.gz (2.7 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page