Catch potential error when posting invalid numbers via REST API

This commit is contained in:
Oliver 2022-02-09 23:26:00 +11:00
parent 001437e083
commit c0e940a898

View File

@ -328,4 +328,7 @@ class InvenTreeDecimalField(serializers.FloatField):
def to_internal_value(self, data):
# Convert the value to a string, and then a decimal
return Decimal(str(data))
try:
return Decimal(str(data))
except:
raise serializers.ValidationError(_("Invalid value"))