A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/tomchristie/django-rest-framework/issues/1964 below:

Automatically determine `select_related` and `prefetch_related` on ModelSerializer. · Issue #1964 · encode/django-rest-framework · GitHub

I have a serializer that looks the the following:

class ReportSerializer(serializers.ModelSerializer):
    person = serializers.SlugRelatedField(slug_field='uuid')

which is causing an N +1 select issue because select_related is not being used to pre-query the Person object. This means that in order to serialize the person field when serializing a Report, each Person must be queried for its uuid.

We likely want to use select_related on all SlugRelatedField and likely all nested serializers somewhere like here: https://github.com/tomchristie/django-rest-framework/blob/e437520217e20d500d641b95482d49484b1f24a7/rest_framework/serializers.py#L570


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4