diff --git a/recipe/models.py b/recipe/models.py index eca4b6d..b332418 100644 --- a/recipe/models.py +++ b/recipe/models.py @@ -52,7 +52,7 @@ class DailyRecipe(models.Model): recipe = Recipe.objects.filter( recipe_type=const.RECIPE_TYPE_MEAT, ).order_by('?').first() - if recipe.id not in recipes and recipe.id not in prev_recipes: + if recipe and recipe.id not in recipes and recipe.id not in prev_recipes: recipes.append(recipe.id) break if retry <= 0: @@ -65,7 +65,7 @@ class DailyRecipe(models.Model): recipe = Recipe.objects.filter( recipe_type=const.RECIPE_TYPE_VEGETABLE, ).order_by('?').first() - if recipe.id not in recipes and recipe.id not in prev_recipes: + if recipe and recipe.id not in recipes and recipe.id not in prev_recipes: recipes.append(recipe.id) break retry -= 1