What are nested serializers, and what performance risks are associated with them?
Last updated
Nested serializers embed one serializer as a field of another (often
many=True) to output related objects inline as structured JSON.The main risks are N+1 queries (extra queries per parent) and large, deeply nested payloads.
Mitigate with
select_relatedandprefetch_related. Writable nesting needs customcreate()/update(), so considerPrimaryKeyRelatedFieldfor writes.