mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-28 11:26:26 -06:00
Fixes #2334: TypeError raised when WritableNestedSerializer receives a non-integer value
This commit is contained in:
parent
7585d63865
commit
8a8b40475c
@ -170,7 +170,9 @@ class WritableNestedSerializer(ModelSerializer):
|
|||||||
if data is None:
|
if data is None:
|
||||||
return None
|
return None
|
||||||
try:
|
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:
|
except ObjectDoesNotExist:
|
||||||
raise ValidationError("Invalid ID")
|
raise ValidationError("Invalid ID")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user