From 5f56cc63f25947fcb89af2edfd535ff2d35e9da3 Mon Sep 17 00:00:00 2001 From: thetarby <45286577+thetarby@users.noreply.github.com> Date: Thu, 31 Dec 2020 21:43:19 +0300 Subject: [PATCH] Apply suggestions from code review cosmetic changes Co-authored-by: Xavier Ordoquy --- docs/api-guide/relations.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/api-guide/relations.md b/docs/api-guide/relations.md index f3dc88e7a..a274b9ba9 100644 --- a/docs/api-guide/relations.md +++ b/docs/api-guide/relations.md @@ -35,12 +35,12 @@ For example, the following serializer would lead to a database hit each time eva fields = ['album_name', 'artist', 'tracks'] # For each album object, tracks should be fetched from database - qs=Album.objects.all() + qs = Album.objects.all() print(AlbumSerializer(qs, many=True).data) If `AlbumSerializer` is used to serialize a fairly large queryset with `many=True` then it could be a serious performance problem. Optimizing the queryset passed to `AlbumSerializer` with: - qs=Album.objects.prefetch_related('tracks') + qs = Album.objects.prefetch_related('tracks') # No additional database hits required print(AlbumSerializer(qs, many=True).data)