diff --git a/awx/api/filters.py b/awx/api/filters.py index 105403bd17..2cf28c7c23 100644 --- a/awx/api/filters.py +++ b/awx/api/filters.py @@ -165,7 +165,13 @@ class FieldLookupBackend(BaseFilterBackend): elif isinstance(field, models.BooleanField): return to_python_boolean(value) elif isinstance(field, (ForeignObjectRel, ManyToManyField, GenericForeignKey, ForeignKey)): - return self.to_python_related(value) + try: + return self.to_python_related(value) + except ValueError: + raise ParseError(_('Invalid {field_name} id: {field_id}').format( + field_name=getattr(field, 'name', 'related field'), + field_id=value) + ) else: return field.to_python(value)