fixed fix of migration
This commit is contained in:
parent
0444286d11
commit
a1160c310c
@ -5,14 +5,14 @@ from django.db import migrations
|
|||||||
|
|
||||||
def migrate_ingredient_units(apps, schema_editor):
|
def migrate_ingredient_units(apps, schema_editor):
|
||||||
Unit = apps.get_model('cookbook', 'Unit')
|
Unit = apps.get_model('cookbook', 'Unit')
|
||||||
RecipeIngredient = apps.get_model('cookbook', 'RecipeIngredient')
|
RecipeIngredients = apps.get_model('cookbook', 'RecipeIngredients')
|
||||||
|
|
||||||
for u in RecipeIngredient.objects.values('unit').distinct():
|
for u in RecipeIngredients.objects.values('unit').distinct():
|
||||||
unit = Unit()
|
unit = Unit()
|
||||||
unit.name = u['unit']
|
unit.name = u['unit']
|
||||||
unit.save()
|
unit.save()
|
||||||
|
|
||||||
for i in RecipeIngredient.objects.all():
|
for i in RecipeIngredients.objects.all():
|
||||||
i.unit_key = Unit.objects.get(name=i.unit)
|
i.unit_key = Unit.objects.get(name=i.unit)
|
||||||
i.save()
|
i.save()
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user