migrating ingredients

This commit is contained in:
vabene1111
2020-02-16 23:12:16 +01:00
parent 81677a74bb
commit f77aa7c8f0
12 changed files with 142 additions and 18 deletions

View File

@@ -5,14 +5,14 @@ from django.db import migrations
def migrate_ingredient_units(apps, schema_editor):
Unit = apps.get_model('cookbook', 'Unit')
RecipeIngredients = apps.get_model('cookbook', 'RecipeIngredients')
RecipeIngredient = apps.get_model('cookbook', 'RecipeIngredient')
for u in RecipeIngredients.objects.values('unit').distinct():
for u in RecipeIngredient.objects.values('unit').distinct():
unit = Unit()
unit.name = u['unit']
unit.save()
for i in RecipeIngredients.objects.all():
for i in RecipeIngredient.objects.all():
i.unit_key = Unit.objects.get(name=i.unit)
i.save()