I am a little disappointed with this problem using the Django Rest Framework:
I am using viewet , p custom serializer
. This serializer has depth set to 1
. When I request this view, I get the correct data view, for example:
data = {
id: 1,
issue_name: 'This is a problem',
status: {
id: 3,
name: 'todo'
}
}
Problem appears when I need to update the status . For example, if I want to select a different status for this problem, for example:
status_new = {
id: 4,
name: 'done'
}
I send the following PATCH back to the server, this is the output:
data = {
id: 1,
issue_name: 'This is a problem',
status: {
id: 4,
name: 'done'
}
}
However, the status is not updated. Infact, it is not even part of the validated_data dictionary. I read that nested relationships are read-only. Can someone please tell me that I need to do this in a simple way?
It would really be a must.
Thank you in advance