Enable cursor pagination of value querysets. by kmwenja · Pull Request #4569 · encode/django-rest-framework (original) (raw)

To do GROUP_BY queries in django requires one to use .values()
eg this groups posts by user getting a count of posts per user.

Posts.objects.order_by('user').values('user').annotate(post_count=Count('post'))

This would produce a value queryset which serializes its result
objects as dictionaries while CursorPagination requires a queryset
with result objects that are model instances.

This commit enables cursor pagination for value querysets.