fixed allow decimals in food property amount

This commit is contained in:
vabene1111
2023-06-26 15:47:44 +02:00
parent dcc56fc138
commit 436158f596
4 changed files with 25 additions and 6 deletions

View File

@ -109,7 +109,7 @@ class CustomDecimalField(serializers.Field):
if data == '':
return 0
try:
return float(data.replace(',', ''))
return float(data.replace(',', '.'))
except ValueError:
raise ValidationError('A valid number is required')
@ -582,6 +582,7 @@ class FoodSerializer(UniqueFieldsMixin, WritableNestedModelSerializer, ExtendedR
properties = PropertySerializer(many=True, allow_null=True, required=False)
properties_food_unit = UnitSerializer(allow_null=True, required=False)
properties_food_amount = CustomDecimalField()
recipe_filter = 'steps__ingredients__food'
images = ['recipe__image']