I have a Django db with cooking recipes. I want to query all users who have at least 80% ingredients to make a recipe. How do I achieve this?
Or how do I query for users who are missing only 1 ingredient for the recipe?
models.py
class ingredient(models.Model):
id = models.AutoField("id",max_length = 100, primary_key=True)
name=models.CharField("Ingredient", max_length=100)
def __unicode__ (self):
return self.name
class user(models.Model):
id = models.AutoField("id",max_length = 100, primary_key=True
ingredient = models.ManyToManyField(ingredient,blank=True)
def __unicode__ (self):
return str(self.id)
class recipe(models.Model):
id = models.AutoField("id", max_length=100, primary_key=True)
recipe_ingredient = models.ManyToManyField(ingredient,related_name='recipe_ingredient',blank=True)
def __unicode__ (self):
return self.id