mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Merge pull request #3289 from koliber/update-docs-serilaizers-multi-update
Added explicit id field in multi update example
This commit is contained in:
commit
6f8e0c3c07
|
@ -775,6 +775,8 @@ To support multiple updates you'll need to do so explicitly. When writing your m
|
|||
* How should removals be handled? Do they imply object deletion, or removing a relationship? Should they be silently ignored, or are they invalid?
|
||||
* How should ordering be handled? Does changing the position of two items imply any state change or is it ignored?
|
||||
|
||||
You will need to add an explicit `id` field to the instance serializer. The default implicitly-generated `id` field is marked as `read_only`. This causes it to be removed on updates. Once you declare it explicitly, it will be available in the list serializer's `update` method.
|
||||
|
||||
Here's an example of how you might choose to implement multiple updates:
|
||||
|
||||
class BookListSerializer(serializers.ListSerializer):
|
||||
|
@ -805,6 +807,8 @@ Here's an example of how you might choose to implement multiple updates:
|
|||
id = serializers.IntegerField()
|
||||
|
||||
...
|
||||
id = serializers.IntegerField(required=False)
|
||||
|
||||
class Meta:
|
||||
list_serializer_class = BookListSerializer
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user