You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
class InvoiceListSerializer(serializers.ModelSerializer):
payer = ContactListSerializer(read_only=True)
class Meta:
model = X
fields = (
'id','number', 'payer'
)
If I want to show a list of 20 invoices, there is 1 SQL request for "id,number" of those 20 invoices AND there are 20 SQL requests for "payer" (one per invoice)
It doesn't seems to be really optimized. Did I miss something? Is it possible to use "join" with DRF ?
Thanks for your help
The text was updated successfully, but these errors were encountered:
For reverse relations, or nested items you'll want to use select_related and/or prefetch_related on the queryset parameter to properly optimize it.
We don't perform this optimization automatically, as it'd introduce too much hidden logic, and would be difficult to debug or override when it doesn't do what you need.
Hi,
I have that kind of serializer
If I want to show a list of 20 invoices, there is 1 SQL request for "id,number" of those 20 invoices AND there are 20 SQL requests for "payer" (one per invoice)
It doesn't seems to be really optimized. Did I miss something? Is it possible to use "join" with DRF ?
Thanks for your help
The text was updated successfully, but these errors were encountered: