fixed ingredient amount numeric

This commit is contained in:
vabene1111
2020-04-07 20:13:20 +02:00
parent f1c5a0ef5f
commit bdd092e5d3
2 changed files with 6 additions and 2 deletions

View File

@ -98,7 +98,10 @@ def internal_recipe_update(request, pk):
recipe_ingredient.ingredient = ingredient
if isinstance(i['amount'], str):
recipe_ingredient.amount = float(i['amount'].replace(',', '.'))
try:
recipe_ingredient.amount = float(i['amount'].replace(',', '.'))
except ValueError:
form.add_error("ingredients", _('There was an error converting your ingredients amount to a number: ') + i['unit__name'])
else:
recipe_ingredient.amount = i['amount']