Hi,
With respect to the issue #2320, the ID field is supposedly to be left out unless it's explicitly set to read_only=False. Does it mean I have to always set it when I want to subclass .update method and define behaviour for a ListSerializer? Otherwise I don't see how this example from API Guide could work (data_mapping):
class BookListSerializer(serializers.ListSerializer):
def update(self, instance, validated_data):
# Maps for id->instance and id->data item.
book_mapping = {book.id: book for book in instance}
data_mapping = {item['id']: item for item in validated_data}
.....
I think it would make more sense to include the ID field in validated_data in ListSerializer despite being read_only.
Thanks for the clarification.
Believe that to be a documentation error - we should be listing the primary key explicitly in that case, so as to not be using the default read-only case. Pull Requests most welcome.
--
You received this message because you are subscribed to a topic in the Google Groups "Django REST framework" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-rest-framework/01ra1-h_J3w/unsubscribe.
To unsubscribe from this group and all its topics, send an email to django-rest-fram...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.