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. - had to mangle the tests a bit to test it out. They might need some refactoring. - tried the same for `.values_list()` but it turned out to be trickier than I expected since you have to use tuple indexes.
Name |
Last commit
|
Last update |
---|---|---|
.tx | Loading commit data... | |
docs | Loading commit data... | |
docs_theme | Loading commit data... | |
requirements | Loading commit data... | |
rest_framework | Loading commit data... | |
tests | Loading commit data... | |
.gitignore | Loading commit data... | |
.isort.cfg | Loading commit data... | |
.travis.yml | Loading commit data... | |
CONTRIBUTING.md | Loading commit data... | |
ISSUE_TEMPLATE.md | Loading commit data... | |
LICENSE.md | Loading commit data... | |
MANIFEST.in | Loading commit data... | |
PULL_REQUEST_TEMPLATE.md | Loading commit data... | |
README.md | Loading commit data... | |
mkdocs.yml | Loading commit data... | |
requirements.txt | Loading commit data... | |
runtests.py | Loading commit data... | |
setup.cfg | Loading commit data... | |
setup.py | Loading commit data... | |
tox.ini | Loading commit data... |