netbox icon indicating copy to clipboard operation
netbox copied to clipboard

Closes #15087: Support for specifying a subset of API serializer fields

Open jeremystretch opened this issue 1 year ago • 2 comments

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_fields property from API views

jeremystretch avatar Feb 12 '24 21:02 jeremystretch

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.)

jeremystretch avatar Feb 12 '24 22:02 jeremystretch

Waiting on PR #15134 to be merged & makes its way into feature

jeremystretch avatar Feb 13 '24 14:02 jeremystretch