Skip to content

Commit

Permalink
fixed SLE create
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed Dec 30, 2024
1 parent 830ce14 commit e219f7e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cookbook/serializer.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,7 +1215,7 @@ def create(self, validated_data):
validated_data['space'] = self.context['request'].space
validated_data['created_by'] = self.context['request'].user

if validated_data['mealplan_id']:
if 'mealplan_id' in validated_data:
slr, created = ShoppingListRecipe.objects.get_or_create(mealplan_id=validated_data['mealplan_id'], mealplan__space=self.context['request'].space)
validated_data['list_recipe'] = slr
del validated_data['mealplan_id']
Expand All @@ -1225,7 +1225,7 @@ def create(self, validated_data):
def update(self, instance, validated_data):
user = self.context['request'].user

if validated_data['mealplan_id']:
if 'mealplan_id' in validated_data:
del validated_data['mealplan_id']

# update the onhand for food if shopping_add_onhand is True
Expand Down

0 comments on commit e219f7e

Please sign in to comment.