diff --git a/docs/api-guide/serializers.md b/docs/api-guide/serializers.md index 89196949d..85682838b 100644 --- a/docs/api-guide/serializers.md +++ b/docs/api-guide/serializers.md @@ -1007,6 +1007,14 @@ The signatures for these methods are as follows: Takes the object instance that requires serialization, and should return a primitive representation. Typically this means returning a structure of built-in Python datatypes. The exact types that can be handled will depend on the render classes you have configured for your API. +May be overridden in order modify the representation style. For example: + + def to_representation(self, instance): + """Convert `username` to lowercase.""" + ret = super().to_representation(instance) + ret['username'] = ret['username'].lower() + return ret + #### ``.to_internal_value(self, data)`` Takes the unvalidated incoming data as input and should return the validated data that will be made available as `serializer.validated_data`. The return value will also be passed to the `.create()` or `.update()` methods if `.save()` is called on the serializer class.