beta/v1: paginate ClientViewSet and add client_name to SiteSerializer#2497
Open
jbloomfield80 wants to merge 1 commit into
Open
beta/v1: paginate ClientViewSet and add client_name to SiteSerializer#2497jbloomfield80 wants to merge 1 commit into
jbloomfield80 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Two small consistency fixes to the
beta/v1API:ClientViewSetis now paginated, matchingSiteViewSet.SiteSerializernow includesclient_name.Motivation
Within
beta/v1, the viewsets are inconsistent:SiteViewSetusesStandardResultsSetPagination(and search/ordering), butClientViewSethas none, soGET /beta/v1/client/returns a bare JSON array whileGET /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:because the client list response isn't the paginated object shape the tooling expects. Separately, the beta
SiteSerializer(fields = "__all__") only carries theclientFK id, so consumers can't display the client name without a second lookup even though the legacy clients API exposesclient_name.Changes
beta/v1/client/views.pyaddpagination_class = StandardResultsSetPaginationtoClientViewSet, plus the sameDjangoFilterBackend/SearchFilter/OrderingFiltersetupSiteViewSetalready uses, withordering = ["id"]for stable paging.beta/v1/serializers.pyaddclient_name = serializers.CharField(source="client.name", read_only=True)toSiteSerializer.Behavior / compatibility
GET /beta/v1/client/now returns the paginatedenvelope (
{count, next, previous, results: [...]}) instead of a bare array.Callers must read
.results. This aligns it with the sibling site endpoint andthe documented DRF pagination behavior. Scoped to the experimental
beta/v1namespace.
SiteViewSetalready returned the paginated shape, so its only change is theadded read-only
client_namefield.page_sizedefaults to 100 (max_page_size1000) via the existingStandardResultsSetPagination.automatically, no manual schema changes needed.
Testing
GET /beta/v1/client/returns the paginated envelope and honors?page,?page_sizeGET /beta/v1/site/includesclient_name.