Implicitly serialize many-to-many relationship when I am posting a nested Through model
Take for example the following payload:
post = {
"@id": "{}/circles/{}/".format(settings.BASE_URL, circle.pk),
"name": "Updated Name",
"members": {
"ldp:contains": [
{"user": {"@id": another_user.urlid }, "is_admin": False},
]
}
}
I am posting a CircleMember
, which is an explicit through model between Circle
and user. I don't define the circle
field in my nested object explicitly, and so when I run:
serializer = CircleSerializer(data=post, instance=circle)
serializer.is_valid(raise_exception=True)
the serializer raises an error. However I shouldn't need to declare this explicitly, because it is implicitly stated by being a child of the parent circle
object, which I have defined. Indeed if I was here posting a new circle then the circle.urlid
would not yet exist