Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Ingredient(models.Model):
- name = models.CharField(max_length=30, primary_key=True)
- qty_on_stock = models.IntegerField()
- def __unicode__(self):
- return self.name
- class Recipe(models.Model):
- name = models.CharField(max_length=30, primary_key=True)
- comments = models.TextField(blank=True)
- ingredient = models.ManyToManyField(Ingredient)
- def __unicode__(self):
- return self.name
- class RecipeContent(models.Model):
- recipe = models.ForeignKey(Recipe)
- ingredients = models.ForeignKey(Ingredient)
- qty_used = models.IntegerField()
- class RecipeContent(models.Model):
- ...
- def __unicode__(self):
- # You can access ForeignKey properties through the field name!
- return self.recipe.name
- class Recipe(models.Model):
- name = models.CharField(max_length=30, primary_key=True)
- comments = models.TextField(blank=True)
- ...
- def __unicode__(self):
- return self.name
- class RecipeContent(models.Model):
- recipe = models.ForeignKey(Recipe)
- ...
- def __unicode__(self):
- return str(self.recipe)
Add Comment
Please, Sign In to add comment