How to limit query results with Django Rest filters

You can use Django Rest Framework pagination. The pagination_class LimitOffsetPagination give you the ability to limit the number of returned entries in a query_param.

http://www.django-rest-framework.org/api-guide/pagination/


You can extend or customize pagination classes available in drf

  class UserSpecificPagination(LimitOffsetPagination):
      def get_limit(self, request):
          if logic_met(request.user):
            self.max_limit = custom_limit
      return super(UserSpecificPagination, self).get_limit(request)

set the class as pagination_class in ListAPIView or DRF settings