def to_internal_value(self, data):
        if isinstance(data, six.string_types) and data.isdigit():
            data = int(data)

        try:
            value = self.enum.get(data).value
        except AttributeError:  # .get() returned None
            if not self.required:
                raise serializers.SkipField()
            self.fail("invalid_choice", input=data)

        return value