From d50fb69ce90fb3783b3bd05f8e2d95ddf2c71b3c Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Sun, 17 Apr 2022 15:48:18 +0200 Subject: [PATCH] fixed errro message in meal plan when adding notes with add to shopping --- cookbook/serializer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cookbook/serializer.py b/cookbook/serializer.py index 4885d59fe..792b65e6c 100644 --- a/cookbook/serializer.py +++ b/cookbook/serializer.py @@ -739,7 +739,7 @@ class MealPlanSerializer(SpacedModelSerializer, WritableNestedModelSerializer): def create(self, validated_data): validated_data['created_by'] = self.context['request'].user mealplan = super().create(validated_data) - if self.context['request'].data.get('addshopping', False): + if self.context['request'].data.get('addshopping', False) and self.context['request'].data.get('recipe', None): SLR = RecipeShoppingEditor(user=validated_data['created_by'], space=validated_data['space']) SLR.create(mealplan=mealplan, servings=validated_data['servings']) return mealplan