Open slamer59 opened 5 years ago
Hi, This is the expected behavior, the DRF-Datatables pagination class delegates pagination to it's parent class when format is different from "datatables", hence the paginated results.
That said, you raise an interesting question, maybe it would be useful to add an option to change this behavior, something like datatables_dont_paginate_non_datatables_format̀
(quite a long name !).
I leave the issue opened as a reminder.
Regards.
I wrote a parent class to override the paginator method. Easy to implement. Maybe it will help someone.
class CustomListAPIView(generics.ListAPIView):
@property
def paginator(self):
"""
The paginator instance associated with the view, or `None`.
"""
if not hasattr(self, '_paginator'):
if self.pagination_class is None:
self._paginator = None
elif self.request.GET.get('format', None) == 'datatables':
self._paginator = self.pagination_class()
else:
self._paginator = None
return self._paginator
class SomeList(CustomListAPIView):
queryset = Some.objects.prefetch_related("others").all()
serializer_class = SomeSerializer
filter_backends = [OrderingFilter]
ordering_fields = '__all__'
Hello, I wonder if it's is normal to change the behavior of json request, eg. ?format=json
I have different API and I just want to use this library for one of them.
For exemple,
becomes
Is it the expected behavior ?
Regards