1👍
I managed to get around this by:
-
Changing AccountSerializer with a
def to_internal_value(self, data):
return Account.objects.get(id=data)
-
Removing the read_only attribute on the field
accounts = AccountSerializer(many=True)
The account only needs to be an id when POST’ing / PUT’ing and the whole account is returned when GET’ing
Source:stackexchange.com