diff options
| author | Tom Christie | 2014-11-25 15:52:36 +0000 |
|---|---|---|
| committer | Tom Christie | 2014-11-25 15:52:36 +0000 |
| commit | d7f8047addaea10b0f629e064a3826e7531d8040 (patch) | |
| tree | 9bd27d74390b313bd1b84a9853531e5814ea24e5 /docs/topics/writable-nested-serializers.md | |
| parent | 64d8e3dcb6846610e1908e067962b0c8457a86f8 (diff) | |
| parent | 66fc51de5c4622073e7e6cfd12cc7c4a1a8ba60c (diff) | |
| download | django-rest-framework-d7f8047addaea10b0f629e064a3826e7531d8040.tar.bz2 | |
Merge branch 'mkdocs' of git://github.com/d0ugal/django-rest-framework into d0ugal-mkdocs
Diffstat (limited to 'docs/topics/writable-nested-serializers.md')
| -rw-r--r-- | docs/topics/writable-nested-serializers.md | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/docs/topics/writable-nested-serializers.md b/docs/topics/writable-nested-serializers.md index abc6a82f..ed614bd2 100644 --- a/docs/topics/writable-nested-serializers.md +++ b/docs/topics/writable-nested-serializers.md @@ -8,7 +8,7 @@ Although flat data structures serve to properly delineate between the individual Nested data structures are easy enough to work with if they're read-only - simply nest your serializer classes and you're good to go. However, there are a few more subtleties to using writable nested serializers, due to the dependencies between the various model instances, and the need to save or delete multiple instances in a single action. -## One-to-many data structures +## One-to-many data structures *Example of a **read-only** nested serializer. Nothing complex to worry about here.* @@ -16,10 +16,10 @@ Nested data structures are easy enough to work with if they're read-only - simpl class Meta: model = ToDoItem fields = ('text', 'is_completed') - + class ToDoListSerializer(serializers.ModelSerializer): items = ToDoItemSerializer(many=True, read_only=True) - + class Meta: model = ToDoList fields = ('title', 'items') @@ -31,7 +31,7 @@ Some example output from our serializer. 'items': { {'text': 'Compile playlist', 'is_completed': True}, {'text': 'Send invites', 'is_completed': False}, - {'text': 'Clean house', 'is_completed': False} + {'text': 'Clean house', 'is_completed': False} } } @@ -44,4 +44,4 @@ Let's take a look at updating our nested one-to-many data structure. ### Making PATCH requests -[cite]: http://jsonapi.org/format/#url-based-json-api
\ No newline at end of file +[cite]: http://jsonapi.org/format/#url-based-json-api |
