normalized ingredients

This commit is contained in:
vabene1111
2020-02-16 23:22:44 +01:00
parent f77aa7c8f0
commit 7d4630e3af
6 changed files with 58 additions and 27 deletions

View File

@ -103,13 +103,13 @@ class Ingredient(models.Model):
class RecipeIngredient(models.Model):
name = models.ForeignKey(Ingredient, on_delete=models.PROTECT, null=True)
ingredient = models.ForeignKey(Ingredient, on_delete=models.PROTECT, null=True)
recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE)
unit = models.ForeignKey(Unit, on_delete=models.PROTECT, null=True)
amount = models.DecimalField(default=0, decimal_places=2, max_digits=16)
def __str__(self):
return str(self.amount) + ' ' + str(self.unit) + ' ' + str(self.name)
return str(self.amount) + ' ' + str(self.unit) + ' ' + str(self.ingredient)
class Comment(models.Model):