def METHOD_NAME(self, validated_data):
    name = validated_data.pop("name")
    if len(name.strip()) == 0:
        raise serializers.ValidationError("Name cannot be empty")
    qs = Person.objects.filter(name=name)
    if qs.count() > 0:
        return qs[0]
    else:
        new_person = Person()
        new_person.name = name
        new_person.save()
        logger.info("created person {}" % new_person.id)
        return new_person