From 8098e74fe2fd736b22414ebb10226254daa15586 Mon Sep 17 00:00:00 2001 From: Andreu Vallbona Plazas Date: Tue, 7 May 2019 18:56:55 +0200 Subject: [PATCH] adding small clarification on ManyToManyFields with a Through Model As pointed here: https://github.com/encode/django-rest-framework/pull/6585#issuecomment-490145334 I suggest to add the small clarification to work with **ManyToManyFields with a Through Model**. --- docs/api-guide/relations.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/docs/api-guide/relations.md b/docs/api-guide/relations.md index 8665e80f6..3ea4980ad 100644 --- a/docs/api-guide/relations.md +++ b/docs/api-guide/relations.md @@ -576,6 +576,8 @@ If you explicitly specify a relational field pointing to a ``ManyToManyField`` with a through model, be sure to set ``read_only`` to ``True``. +If you wish to represent [extra fields on a through model][django-intermediary-manytomany] then you may serialize the through model as [a nested object][dealing-with-nested-objects]. + --- # Third Party Packages @@ -596,3 +598,6 @@ The [rest-framework-generic-relations][drf-nested-relations] library provides re [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 + +[django-intermediary-manytomany]: https://docs.djangoproject.com/en/2.2/topics/db/models/#intermediary-manytomany +[dealing-with-nested-objects]: https://www.django-rest-framework.org/api-guide/serializers/#dealing-with-nested-objects