1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Fixes #2334: TypeError raised when WritableNestedSerializer receives a non-integer value

This commit is contained in:
Jeremy Stretch
2018-08-08 15:09:30 -04:00
parent 134370f48d
commit a2ff21fab9

View File

@ -170,7 +170,9 @@ class WritableNestedSerializer(ModelSerializer):
if data is None:
return None
try:
return self.Meta.model.objects.get(pk=data)
return self.Meta.model.objects.get(pk=int(data))
except (TypeError, ValueError):
raise ValidationError("Primary key must be an integer")
except ObjectDoesNotExist:
raise ValidationError("Invalid ID")