mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-12-02 22:43:46 +03:00
21 lines
567 B
Python
21 lines
567 B
Python
|
from django.db import models
|
||
|
|
||
|
from cookbook.ingredients.models import Ingredient
|
||
|
|
||
|
|
||
|
class Recipe(models.Model):
|
||
|
title = models.CharField(max_length=100)
|
||
|
instructions = models.TextField()
|
||
|
|
||
|
|
||
|
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'),
|
||
|
))
|