diff --git a/apps/applications/serializers/remote_app.py b/apps/applications/serializers/remote_app.py index 90f32f8cd..65190f38c 100644 --- a/apps/applications/serializers/remote_app.py +++ b/apps/applications/serializers/remote_app.py @@ -21,17 +21,11 @@ logger = get_logger(__file__) class CharPrimaryKeyRelatedField(serializers.PrimaryKeyRelatedField): def to_internal_value(self, data): - if self.pk_field is not None: - data = self.pk_field.to_internal_value(data) - try: - instance = self.get_queryset().get(pk=data) - return str(instance.id) - except ObjectDoesNotExist: - self.fail('does_not_exist', pk_value=data) - except (TypeError, ValueError): - self.fail('incorrect_type', data_type=type(data).__name__) + instance = super().to_internal_value(data) + return str(instance.id) def to_representation(self, value): + # value is instance.id if self.pk_field is not None: return self.pk_field.to_representation(value) return value