I had a use case where I had to implement a multiple update endpoint; and 
for the most part I followed docs 
https://www.django-rest-framework.org/api-guide/serializers/#customizing-multiple-update

however in my case I could not include the pk/id on the child serializer 
because this is being used for integration work from an external data 
source that is unaware of our pks.

The instance kwarg that I pass to the ListSerializer is a queryset that 
filters on an alternate key.

This queryset also gets passed as the instance kwarg to the child 
serializer, where it expects an object instance and not a queryset.

The issue manifested as an AttributeError in the validators where a 
queryset has no attribute pk: on this line 
https://github.com/encode/django-rest-framework/blob/4abfa28e0879e2df45937ac8c7a9ffa161561955/rest_framework/validators.py#L60

I'm still unsure of how to appropriately pass single instances, or lack 
thereof to the child serializer for validation.  Another thought I had was 
to override some method on the child (before validation) to set 
self.instance

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-rest-framework/5cebb208-05ea-47f5-ae2a-c12c5aaff29an%40googlegroups.com.

Reply via email to