I am reading the Django REST Framework, and I have a model that is serialized using getters using SerializerMethodField () .
However, when I send POST to this endpoint, I also want to set this field, but this does not work, because, as shown above, you cannot write to SerializerMethodField. Is there a way in Django REST to have a serializer field for which you define a custom getter method and a custom label method?
EDIT: Here is the source of what I'm trying to do. The client has a 1 to 1 relationship with the user.
class ClientSerializer(serializers.ModelSerializer): email = serializers.SerializerMethodField() def create(self, validated_data): email = validated_data.get("email", None)
source share