def to_internal_value(self, data):
        if self.pk_field is not None:
            data = self.pk_field.to_internal_value(data)
        try:
            return self.get_queryset().get(pk=data)
        except __HOLE__:
            self.fail('does_not_exist', pk_value=data)
        except (TypeError, ValueError):
            self.fail('incorrect_type', data_type=type(data).__name__)
dataset/ETHPy150Open tomchristie/django-rest-framework/rest_framework/relations.py/PrimaryKeyRelatedField.to_internal_value