netbox
netbox copied to clipboard
Closes #15087: Support for specifying a subset of API serializer fields
Fixes: #15087
- Introduces support for specifying a subset of serializer fields to be returned in a REST API request (e.g.
GET /api/dcim/sites/?fields=id,name,status,region) - Introduces the
get_prefetches_for_serializer()utility function - Extends the base API viewset to automatically resolve the necessary queryset prefetches for a serializer based on the requested fields
- Removes all now-unnecessary explicit calls to
prefetch_related()on API views (a few remain for various reasons) - Removes the
brief_prefetch_fieldsproperty from API views
The test failure is due to a bug in the nested serializer for FHRP group assignments. (It should be returning group rather than group_id.)
Waiting on PR #15134 to be merged & makes its way into feature