1👍
Make Your own Paginator
class with
class MyPaginator(Paginator):
def page(self):
...
count = self.get_count(limit=limit, offset=offset)
...
def get_count(self, limit=None, offset=None):
if limit in (0, self.max_limit) and offset == 0:
return len(list(self.objects))
else:
return super(MyPaginator, self).get_count()
This works when limit = 0
and offset = 0
. In other cases Tastypie must count all elements to make next and prev links and meta.total_count
.
This code is from tastypie-extras package.
Source:stackexchange.com