This commit is contained in:
nikolas 2018-04-20 14:00:42 +00:00 committed by GitHub
commit 443432572d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -290,6 +290,8 @@ Would serialize to a nested representation like this:
By default nested serializers are read-only. If you want to support write-operations to a nested serializer field you'll need to create `create()` and/or `update()` methods in order to explicitly specify how the child relationships should be saved.
Note that django-rest-framework's [MultiPartRenderer] doesn't handle writing nested data properly, so if you're going to be testing this functionality, you'll need to add `format='json'` to your test requests.
class TrackSerializer(serializers.ModelSerializer):
class Meta:
model = Track
@ -594,7 +596,8 @@ The [rest-framework-generic-relations][drf-nested-relations] library provides re
[cite]: https://lwn.net/Articles/193245/
[reverse-relationships]: https://docs.djangoproject.com/en/stable/topics/db/queries/#following-relationships-backward
[routers]: http://www.django-rest-framework.org/api-guide/routers#defaultrouter
[routers]: https://www.django-rest-framework.org/api-guide/routers#defaultrouter
[generic-relations]: https://docs.djangoproject.com/en/stable/ref/contrib/contenttypes/#id1
[drf-nested-routers]: https://github.com/alanjds/drf-nested-routers
[drf-nested-relations]: https://github.com/Ian-Foote/rest-framework-generic-relations
[MultiPartRenderer]: https://www.django-rest-framework.org/api-guide/renderers/#multipartrenderer