def to_internal_value(self, data):
        if data['type'] != get_resource_type_from_model(self.model_class):
            self.fail('incorrect_model_type', model_type=self.model_class, received_type=data['type'])
        pk = data['id']
        try:
            return self.model_class.objects.get(pk=pk)
        except ObjectDoesNotExist:
            self.fail('does_not_exist', pk_value=pk)
        except (__HOLE__, ValueError):
            self.fail('incorrect_type', data_type=type(data['pk']).__name__)
dataset/ETHPy150Open django-json-api/django-rest-framework-json-api/rest_framework_json_api/serializers.py/ResourceIdentifierObjectSerializer.to_internal_value