Closed tomchristie closed 9 years ago
How might a cursor-based pagination implementation work in these upcoming improvements?
Facebook SDK page has a good description: https://developers.facebook.com/docs/reference/api/pagination/
And here is a solution for Django nonrel: https://github.com/potatolondon/potatopage?source=c http://p.ota.to/blog/2013/04/pagination-with-cursors-in-the-app-engine-datastore/
How might a cursor-based pagination implementation work in these upcoming improvements?
The pagination API should be able to support cursor style paginations as well as numbered paging, but we not actually provide those implementations.
Please don't make implementers deal with trivial (and possibly non-trivial) features over and over again. If you are going to drop the numbered paging implementation that would be bad for the community and the project.
If you are going to drop the numbered paging implementation
There's no plan for that to happen.
@tomchristie Sorry I misunderstood you then. What did you mean?
I meant to say that we might not necessarily provide any extra implementations in addition to the existing style.
On 3 November 2013 14:12, Omer Katz notifications@github.com wrote:
@tomchristie https://github.com/tomchristie Sorry I misunderstood you then. What did you mean?
— Reply to this email directly or view it on GitHubhttps://github.com/tomchristie/django-rest-framework/issues/1169#issuecomment-27645242 .
not saying it's a great idea, but as an immediate workaround if you need (or at least want) e.g. limit/offset (Of course people are moving to opaque cursor, limit/offset is just an example) note you can e.g. apply them directly as a bodged django-filter rather than a paginator as in e.g. https://gist.github.com/dgoldensquared/8668831#file-limoff-py
This has an interesting (and conceivably useful) effect the existing oldschool pagination is then applied within the limited/offset results.
I guess, not planned on DRF 2? >_>
I guess, not planned on DRF 2
Improving the pagination API is still very much on the roadmap, yup! See the first stretch goal, here... https://www.kickstarter.com/projects/tomchristie/django-rest-framework-3
Note that this ticket should include addressing #1538 if necessary.
We have implemented pagination support to use headers instead of modifying the output - https://github.com/opennode/nodeconductor/blob/develop/nodeconductor/core/mixins.py#L104 . @tomchristie, if you think it's of a value, I can formulate a more proper pull request.
It's prob worth waiting for the pagination API before looking at a PR for an implementation, but yes that'd be great once we start pulling 3.1 together!
Note: lots of progress on this currently in the 3.1 branch.
Some possible remaining tweaks:
get_ordering
API (eg remove queryset from it)Is there a plan to implement also Headers-based pagination?
There is an example in the docs (in the incoming version-3.1 branch) that shows how to do it.
So yes, we'll be supporting it, but the built-in schemes won't use it directly - the Link
header is probably a little awkward for some clients to parse, so happy for the defaults to all use in-body pagination info.
so 3.1 is RC now?
Released.
Link to draft release announcement
Headline features include:
Required
Optional
Strip '=' on cursor based pagination.Ensure we handle None, True, False values on cursor based pagination.Consider further performance improvements based on benchmarking. (Esp improve the common case for attribute lookup on fields)- Dropped. To be considered for 3.2.Add example forserializer_field_mappings
(and consider allowing partial overrides.)Decide if- DroppedDurationField
should make the cut, given that we're headlining the 1.8 fields - if we've got this all mostly wrapped up then we could move it in.