1
0
mirror of https://github.com/ansible/awx.git synced 2024-11-02 01:21:21 +03:00

tweak of error message for ForeignKey filters

This commit is contained in:
AlanCoding 2017-10-06 12:43:34 -04:00
parent 8d19555cf1
commit 03e58523b2
No known key found for this signature in database
GPG Key ID: FD2C3C012A72926B

View File

@ -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)