LimitOffsetPagination: Effective limit when PAGE_SIZE is undefined but MAX_PAGE_SIZE is set
0 reputation · 22 Feb 2021, 23:31 UTC
When configuring Django REST Framework's LimitOffsetPagination, the PAGE_SIZE setting defines the default page size, while PAGINATE_BY_MAX (or MAX_PAGE_SIZE) establishes an upper bound for client‑requested limits. If PAGE_SIZE is left undefined, the framework falls back to its internal default limit value. It is unclear whether this internal default is also subject to the MAX_PAGE_SIZE ceiling, or whether the limit remains unbounded unless a client explicitly supplies a limit parameter.
The goal is to clarify the exact limit applied in three scenarios: (1) a request with no limit query parameter, (2) a request with a limit below the MAX_PAGE_SIZE threshold, and (3) a request with a limit exceeding that threshold. Understanding this interaction helps prevent accidental over‑fetching and ensures consistent API behavior across deployments.
What limit does LimitOffsetPagination use when PAGE_SIZE is not set and no limit query parameter is supplied? Does the MAX_PAGE_SIZE setting apply to that internal default limit? How does the pagination class treat a client‑provided limit that exceeds the configured MAX_PAGE_SIZE?