Advertisement
Guest User

Untitled

a guest
Jun 16th, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.30 KB | None | 0 0
  1. class Ingredient(models.Model):
  2. name = models.CharField(max_length=255)
  3.  
  4. class Recipe(models.Model):
  5. name = models.CharField(max_length=255)
  6. ingredients = models.ManyToManyField(Ingredient)
  7.  
  8. count = 0
  9. for recipe in Recipe.objects.all():
  10. count += recipe.ingredients.count()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement