Skip to content

beta/v1: paginate ClientViewSet and add client_name to SiteSerializer#2497

Open
jbloomfield80 wants to merge 1 commit into
amidaware:developfrom
RKBlack:develop
Open

beta/v1: paginate ClientViewSet and add client_name to SiteSerializer#2497
jbloomfield80 wants to merge 1 commit into
amidaware:developfrom
RKBlack:develop

Conversation

@jbloomfield80

Copy link
Copy Markdown

Summary

Two small consistency fixes to the beta/v1 API:

  1. ClientViewSet is now paginated, matching SiteViewSet.
  2. The beta SiteSerializer now includes client_name.

Motivation

Within beta/v1, the viewsets are inconsistent: SiteViewSet uses StandardResultsSetPagination (and search/ordering), but ClientViewSet has none, so GET /beta/v1/client/ returns a bare JSON array while GET /beta/v1/site/ returns the standard DRF envelope (count/next/previous/results).

This breaks external tooling that consumes the paginated beta API. Iintegrating Organization Mappings in Rewst (which expects a paginated, array-yielding endpoint) fails against /beta/v1/client/ with:

list indices must be integers or slices, not str

because the client list response isn't the paginated object shape the tooling expects. Separately, the beta SiteSerializer (fields = "__all__") only carries the client FK id, so consumers can't display the client name without a second lookup even though the legacy clients API exposes client_name.

Changes

  • beta/v1/client/views.py add pagination_class = StandardResultsSetPagination to ClientViewSet, plus the same DjangoFilterBackend/SearchFilter/OrderingFilter setup SiteViewSet already uses, with ordering = ["id"] for stable paging.
  • beta/v1/serializers.py add client_name = serializers.CharField(source="client.name", read_only=True) to SiteSerializer.

Behavior / compatibility

  • Response-shape change: GET /beta/v1/client/ now returns the paginated
    envelope ({count, next, previous, results: [...]}) instead of a bare array.
    Callers must read .results. This aligns it with the sibling site endpoint and
    the documented DRF pagination behavior. Scoped to the experimental beta/v1
    namespace.
  • SiteViewSet already returned the paginated shape, so its only change is the
    added read-only client_name field.
  • page_size defaults to 100 (max_page_size 1000) via the existing
    StandardResultsSetPagination.
  • The OpenAPI schema (drf-spectacular) reflects the new paginated client response
    automatically, no manual schema changes needed.

Testing

  • Verified GET /beta/v1/client/ returns the paginated envelope and honors
    ?page, ?page_size
  • Verified GET /beta/v1/site/ includes client_name.
  • Running in production after a snapshot, in addition to a separate test instance.

@CLAassistant

CLAassistant commented Jun 17, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants