mirror of
https://github.com/encode/django-rest-framework.git
synced 2025-08-02 11:30:12 +03:00
Merge 374e9d4d8d
into 7d64b7016d
This commit is contained in:
commit
443432572d
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user