From 671ea27d9f8fb375bbb70669269df176c85f3b96 Mon Sep 17 00:00:00 2001 From: Chris Giacofei Date: Fri, 21 Jun 2024 11:32:53 -0400 Subject: [PATCH] Add many to many field with through relationship for fermentables. Gives direct access to fermentable objects. --- beer/migrations/0012_recipe_fermentables.py | 18 ++++++++++++++++++ beer/models.py | 2 ++ 2 files changed, 20 insertions(+) create mode 100644 beer/migrations/0012_recipe_fermentables.py diff --git a/beer/migrations/0012_recipe_fermentables.py b/beer/migrations/0012_recipe_fermentables.py new file mode 100644 index 0000000..9e29297 --- /dev/null +++ b/beer/migrations/0012_recipe_fermentables.py @@ -0,0 +1,18 @@ +# Generated by Django 5.0.6 on 2024-06-21 13:59 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('beer', '0011_rename_batchrecipe_recipe'), + ] + + operations = [ + migrations.AddField( + model_name='recipe', + name='fermentables', + field=models.ManyToManyField(through='beer.RecipeFermentable', to='beer.fermentable'), + ), + ] diff --git a/beer/models.py b/beer/models.py index 3be513a..64c75da 100644 --- a/beer/models.py +++ b/beer/models.py @@ -106,6 +106,8 @@ class Recipe(CustomModel): max_digits=6, decimal_places=2, default=75) batch_size = models.DecimalField( max_digits=6, decimal_places=2, default=11) + fermentables = models.ManyToManyField( + 'Fermentable', through='RecipeFermentable') class Meta: verbose_name = 'Recipe'