Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Support for nulls_first / nulls_last in CursorPagination#9456

Unanswered
jonatanvm asked this question inIdeas & Suggestions
Discussion options

Django supportsasc(nulls_first=None, nulls_last=None) anddesc(nulls_first=None, nulls_last=None), but DRF does not.
Even if you write your own OrderingFilter which orders the results with nulls last, CursorPagination will override that in:

if reverse:    queryset = queryset.order_by(*_reverse_ordering(self.ordering))else:    queryset = queryset.order_by(*self.ordering)

My suggestion is to add a configurable class variable that let's us configure whether nulls will be sorted first or last. Alternatively it would be helpful if ordering was extracted to a function that could be overridden.

You must be logged in to vote

Replies: 2 comments

Comment options

I was also looking to discuss the same feature. If this feature is added, it will be a great help.

You must be logged in to vote
0 replies
Comment options

This could be achieved by usingQueryset.reverse() instead thant providing the method_reverse_ordering.

However it would be very nice if theOrderingField would have some kind of built-in support for Django ordering options for NULLs.

You must be logged in to vote
0 replies
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Labels
None yet
3 participants
@jonatanvm@sevdog@yangchoi

[8]ページ先頭

©2009-2025 Movatter.jp