Skip to content

Commit 6f8e0c3

Browse files
committed
Merge pull request encode#3289 from koliber/update-docs-serilaizers-multi-update
Added explicit id field in multi update example
2 parents 69e1489 + dae5426 commit 6f8e0c3

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

docs/api-guide/serializers.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,8 @@ To support multiple updates you'll need to do so explicitly. When writing your m
774774
* How should insertions be handled? Are they invalid, or do they create new objects?
775775
* How should removals be handled? Do they imply object deletion, or removing a relationship? Should they be silently ignored, or are they invalid?
776776
* How should ordering be handled? Does changing the position of two items imply any state change or is it ignored?
777+
778+
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.
777779

778780
Here's an example of how you might choose to implement multiple updates:
779781

@@ -805,6 +807,8 @@ Here's an example of how you might choose to implement multiple updates:
805807
id = serializers.IntegerField()
806808

807809
...
810+
id = serializers.IntegerField(required=False)
811+
808812
class Meta:
809813
list_serializer_class = BookListSerializer
810814

0 commit comments

Comments
 (0)