I opened this issue here:
https://github.com/encode/django-rest-framework/issues/8658

About the update example for a list 
serializer: 
https://www.django-rest-framework.org/api-guide/serializers/#customizing-multiple-update

The update method for a LIST serializer *creates*, *updates*, and *deletes* 
objects. The comments in the code are " # Perform creations and updates." 
and "# Perform deletions.".
The issue was just closed by Tom Christie without any thought saying "this 
is the update method".

Unfortunately the create logic is flawed, because if there is more than 1 
item to create, it will either not have an id, or they will both be have a 
key of None, and hence:

data_mapping = {item['id']: item for item in validated_data}
Will override any existing key or raise an error. The result or is either 
an error, or worse silently only ever updating one item in the list.

Its hard enough to learn DRF without examples that don't work.

Kind Regards

-- 
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/8fca26eb-95d1-4821-8b82-f0b7b63c9a9dn%40googlegroups.com.

Reply via email to