Discussion:
Serializer with PrimaryKeyRelatedField many=True produces lots of queries when is_valid is called
Wasp
2018-07-12 07:54:44 UTC
Permalink
I'm using Serializers to transform primary keys into model instances with
DRF by using the PrimaryKeyRelatedField.
However, when I run the is_valid() method on the serializers to get the
validated data for every primary key a query is produced by performing a
get on the provided queryset.
With large numbers this becomes very inefficient. Is there a way to trigger
a .filter() on the queryset or a better way of doing this? I know I can
just do a filter on the queryset myself but I like the structured way of
doing this via Serializers.

Thanks!
--
You received this message because you are subscribed to the Google Groups "Django REST framework" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-rest-framework+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...