-
-
Notifications
You must be signed in to change notification settings - Fork 546
Feature/cursor-paginator #1584
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Feature/cursor-paginator #1584
Conversation
1eecf86 to
d12575e
Compare
|
Hi @janrito I think thi default is not practicaly - not many will have 'created' - maybe default should be '-pk' ? PAGINATION_DEFAULT_ORDERING: tuple[str, ...] = Field(
("-created",), alias="NINJA_PAGINATION_DEFAULT_ORDERING"
) |
ce7e7c1 to
98dd599
Compare
|
FWIW - this is related to #836 (FYI @zachmullen). |
yep – that is one of the implementations I used as reference. Listed above as https://github.com/kitware-resonant/django-ninja-cursor-pagination/tree/master/ninja_cursor_pagination |
|
Is there anything else I can do to help, @vitalik ? |
|
@janrito looks like it sitll crashing |
98dd599 to
1fe184e
Compare
|
Hi @vitalik sorry for the delay, got a bit busy.
|
1fe184e to
a1c008a
Compare
a1c008a to
5528fdf
Compare
|
Have rebased again from main. test pass, but still getting these mypy errors that are unrelated to the work in this branch: ruff format --preview --check ninja tests
150 files already formatted
ruff check --preview ninja tests
All checks passed!
mypy ninja
ninja/params/models.py:193: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:256: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:260: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:264: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:268: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:272: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:276: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:280: error: Unused "type: ignore" comment [unused-ignore]
ninja/params/models.py:284: error: Unused "type: ignore" comment [unused-ignore]
ninja/testing/client.py:209:28: error: Item "StreamingHttpResponse" of "Response | StreamingHttpResponse" has no attribute "content" [union-attr]
Found 10 errors in 2 files (checked 49 source files)
make: *** [lint] Error 1
|
Hi
I have implemented a version of
CursonPaginatorbased on ideas from both:https://github.com/kitware-resonant/django-ninja-cursor-pagination/tree/master/ninja_cursor_pagination
and https://github.com/encode/django-rest-framework/blob/2465f9b4876ce16f2d22aa8d9f3cd20abde1b7c8/rest_framework/pagination.py#L583
This is an attempt for a minimal implementation that serves my needs, happy to hear any feedback.
It defines a custom paginator which can be added to any call:
It defaults to using
-createdas the positioning attribute and allows for additional ordering attributes. These, along a page_size and max_page_size can be customised per view:Where
start_dateis the positioning attribute