I am currently trying to use the Django ORM to query the Recipe
model's ingredients.
class Recipe(models.Model):
account = models.ForeignKey(CustomUser, on_delete=models.CASCADE, null=True, blank=True)
name = models.TextField(null=True, blank=True)
class RecipeIngredients(models.Model):
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, null=True)
ingredient = models.TextField(null=True, blank=True)
What I have so far is
ingredients = ["eggs", "bacon", "potato"]
recipes = Recipe.objects.filter(
recipeingredients__ingredient__in=ingredients
).alias(
ningredient=Count('recipeingredients')
).filter(
ningredient__gte=len(ingredients)
)
From my understanding of this answer this will return all the items that contain only "eggs", "bacon", and "potato", but not say Eggs or Scrambled EGGS. Is there anyway to adjust this to have it search for all items that contains the ingredients and case insensative?