From 22b6c3baa2d9e0b99d5851dd86e080445f591a83 Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 1 Dec 2019 23:24:31 +0100 Subject: [PATCH] auto convert decimal seperator in ingredients --- cookbook/views/edit.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cookbook/views/edit.py b/cookbook/views/edit.py index a11e2f96f..6a1583387 100644 --- a/cookbook/views/edit.py +++ b/cookbook/views/edit.py @@ -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()