Skip to main content

pypaginate.adapters.django.sorting

Translate sort specs to Django order_by arguments.

Without null placement a key renders to a plain "field" / "-field" string; with nulls set it renders to an F(field).asc(nulls_last=...) / .desc(nulls_first=...) expression (Django emulates NULLS FIRST/LAST on backends lacking native support).

build_order_by

def build_order_by(sorting: Sequence[SortSpec]) -> list[Any]

Render sort specs to a list of order_by arguments.

apply_sorting

def apply_sorting(queryset: Any, sorting: Sequence[SortSpec]) -> Any

Apply ordered sort specs to a QuerySet (no-op when empty).