2017-02-14 21:23:45 +03:00
|
|
|
from django.db import models
|
|
|
|
|
|
|
|
from cookbook.ingredients.models import Ingredient
|
|
|
|
|
|
|
|
|
|
|
|
class Recipe(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
instructions = models.TextField()
|
2018-06-13 17:13:27 +03:00
|
|
|
__unicode__ = lambda self: self.title
|
2017-02-14 21:23:45 +03:00
|
|
|
|
|
|
|
|
|
|
|
class RecipeIngredient(models.Model):
|
|
|
|
recipe = models.ForeignKey(Recipe, related_name='amounts')
|
|
|
|
ingredient = models.ForeignKey(Ingredient, related_name='used_by')
|
|
|
|
amount = models.FloatField()
|
|
|
|
unit = models.CharField(max_length=20, choices=(
|
|
|
|
('unit', 'Units'),
|
|
|
|
('kg', 'Kilograms'),
|
|
|
|
('l', 'Litres'),
|
|
|
|
('st', 'Shots'),
|
|
|
|
))
|