2017-02-14 21:23:45 +03:00
|
|
|
from django.db import models
|
|
|
|
|
2018-10-18 21:33:53 +03:00
|
|
|
from ..ingredients.models import Ingredient
|
2017-02-14 21:23:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
class Recipe(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
instructions = models.TextField()
|
2019-06-11 06:54:30 +03:00
|
|
|
|
2018-10-18 21:33:53 +03:00
|
|
|
def __str__(self):
|
|
|
|
return self.title
|
2017-02-14 21:23:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
class RecipeIngredient(models.Model):
|
2019-06-11 06:54:30 +03:00
|
|
|
recipe = models.ForeignKey(Recipe, related_name="amounts", on_delete=models.CASCADE)
|
|
|
|
ingredient = models.ForeignKey(
|
|
|
|
Ingredient, related_name="used_by", on_delete=models.CASCADE
|
|
|
|
)
|
2017-02-14 21:23:45 +03:00
|
|
|
amount = models.FloatField()
|
2019-06-11 06:54:30 +03:00
|
|
|
unit = models.CharField(
|
|
|
|
max_length=20,
|
|
|
|
choices=(
|
|
|
|
("unit", "Units"),
|
|
|
|
("kg", "Kilograms"),
|
|
|
|
("l", "Litres"),
|
|
|
|
("st", "Shots"),
|
|
|
|
),
|
|
|
|
)
|