Skip to main content

pypaginate.adapters.django.filters

Translate filter specs/groups to Django Q objects.

Each operator maps to a Django field lookup. The in-memory-only empty / not_empty / exists operators have no SQL equivalent and raise :class:~pypaginate.errors.FilterError. like / ilike map to (case-insensitive) substring lookups; SQL LIKE wildcards are not interpreted.

build_filter_q

def build_filter_q(filters: Sequence[FilterSpec] | FilterGroup) -> Any

Build a Django Q from a flat spec list or a nested AND/OR group.

apply_filters

def apply_filters(queryset: Any,
filters: Sequence[FilterSpec] | FilterGroup) -> Any

Apply filter specs/group to a QuerySet (no-op when empty).