Disable it and check if the problem still persist. On Wednesday, November 2, 2016 at 6:32:33 PM UTC+2, David Miranda wrote: > > I recently introduced django cachalot (redis cache). Can be this? > > quarta-feira, 2 de Novembro de 2016 às 16:26:30 UTC, Norbert Mate escreveu: >> >> Then I would need more info to be able to try to help. Can you share some >> code? >> >> On Wednesday, November 2, 2016 at 6:19:04 PM UTC+2, David Miranda wrote: >>> >>> I'm already using a custom pagination class. The problem is that when >>> this happens the list method is not invoked. >>> >>> quarta-feira, 2 de Novembro de 2016 às 16:09:44 UTC, Norbert Mate >>> escreveu: >>>> >>>> And don't forget to set the page_size query param when you are making >>>> the request or set the default page size in the settings: >>>> >>>> 'PAGE_SIZE': 10, >>>> >>>> >>>> >>>> >>>> On Wednesday, November 2, 2016 at 5:11:55 PM UTC+2, Norbert Mate wrote: >>>>> >>>>> The problem might be that the generic views list method (like >>>>> ListApiView) returns a list of objects it the page is None. >>>>> >>>>> def list(self, request, *args, **kwargs): >>>>> queryset = self.filter_queryset(self.get_queryset()) >>>>> >>>>> page = self.paginate_queryset(queryset) >>>>> if page is not None: >>>>> serializer = self.get_serializer(page, many=True) >>>>> return self.get_paginated_response(serializer.data) >>>>> >>>>> serializer = self.get_serializer(queryset, many=True) >>>>> return Response(serializer.data) >>>>> >>>>> The problem might be in the default pagination class (in >>>>> PageNumberPagination the page_size_query_param is set to None). To fix >>>>> this >>>>> I have created a custom pagination class: >>>>> https://gist.github.com/robintema/a2dee269041325d19d47d78853ed4572 >>>>> >>>>> Use it by overwriting the default pagination class: >>>>> REST_FRAMEWORK = { >>>>> … >>>>> 'DEFAULT_PAGINATION_CLASS': >>>>> ‘path.to.pagination.CustomPageNumberPagination', >>>>> … >>>>> } >>>>> >>>>> >>>>> >>>>> On Wednesday, November 2, 2016 at 3:13:37 PM UTC+2, David Miranda >>>>> wrote: >>>>>> >>>>>> Yes! Any suspicion of what might be ? >>>>>> >>>>>> Regards >>>>>> >>>>>> quarta-feira, 2 de Novembro de 2016 às 10:57:18 UTC, Norbert Mate >>>>>> escreveu: >>>>>>> >>>>>>> Hi, >>>>>>> does this happen if the result size is smaller than the requested >>>>>>> items per page? Example: you have 3 items in the db and from the >>>>>>> frontend >>>>>>> you request 10. >>>>>>> >>>>>>> Regards, >>>>>>> Norbert. >>>>>>> >>>>>>> On Monday, October 31, 2016 at 9:43:27 PM UTC+2, David Miranda wrote: >>>>>>>> >>>>>>>> Hi, >>>>>>>> >>>>>>>> The pagination in my APIs (ModelViewSet) does not always work. >>>>>>>> Sometimes returns the paged results and sometimes not (the >>>>>>>> get_paginated_response method is not executed). I have the settings >>>>>>>> set >>>>>>>> pagination class and the PAGE_SIZE parameter. A >>>>>>>> Thanks >>>>>>>> >>>>>>>
-- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
