auto convert decimal seperator in ingredients

This commit is contained in:
vabene1111
2019-12-01 23:24:31 +01:00
parent fb267b662c
commit 22b6c3baa2

View File

@@ -52,7 +52,10 @@ def internal_recipe_update(request, pk):
ingredient = RecipeIngredients()
ingredient.recipe = recipe_instance
ingredient.name = i['name']
ingredient.amount = i['amount']
if isinstance(i['amount'], str):
ingredient.amount = float(i['amount'].replace(',', '.'))
else:
ingredient.amount = i['amount']
ingredient.unit = i['unit']
ingredient.save()