def rename_serializer_field(serializer, source_name, target_name,
    display_name=None):
    """Renames specified field of a serializer optionally updating its label.

    Useful to make field set of a serialized representation of an entity differ from the original one.

    Parameters:

    - serializer #rest_framework.serializers.Serializer: The serializer instance to rename field of.
    - source_name #str: The original name of the field.
    - target_name #str: The desired name of the field.
    - display_name #str: The updated label of the field (optional).

    See also:

    - [DRF Serializer Field Label](https://www.django-rest-framework.org/api-guide/fields/#label)
    """
    field = serializer.fields.pop(source_name)
    if display_name is not None:
        field.label = display_name
    serializer.fields[target_name] = field
