Closes #21244: Introduce ability to omit specific fields from REST API responses #455

Closed
opened 2026-04-05 16:33:41 +02:00 by MrUnknownDE · 0 comments
Owner

Originally created by @jeremystretch on 1/28/2026

Closes: #21244

  • Extend BaseModelSerializer to accept the omit keyword argument on initialization.
  • Replace requested_fields() on BaseViewSet with field_kwargs(), which returns a dictionary to pass as kwargs when instantiating the serializer (e.g. {'fields': [...]}).
  • Update the get_prefetches_for_serializer() and get_annotations_for_serializer() functions to accept fields or omit.
  • Add documentation for the fields and omit parameters.
*Originally created by @jeremystretch on 1/28/2026* ### Closes: #21244 - Extend BaseModelSerializer to accept the `omit` keyword argument on initialization. - Replace `requested_fields()` on BaseViewSet with `field_kwargs()`, which returns a dictionary to pass as kwargs when instantiating the serializer (e.g. `{'fields': [...]}`). - Update the `get_prefetches_for_serializer()` and `get_annotations_for_serializer()` functions to accept `fields` or `omit`. - Add documentation for the `fields` and `omit` parameters.
Sign in to join this conversation.
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github/netbox#455