TandoorRecipes/cookbook/migrations/0059_auto_20200625_2137.py
2021-02-21 15:34:35 +01:00

26 lines
676 B
Python

# Generated by Django 3.0.7 on 2020-06-25 19:37
from django.db import migrations
from django_scopes import scopes_disabled
def migrate_ingredients(apps, schema_editor):
with scopes_disabled():
Recipe = apps.get_model('cookbook', 'Recipe')
Ingredient = apps.get_model('cookbook', 'Ingredient')
for r in Recipe.objects.all():
for i in Ingredient.objects.filter(recipe=r).all():
r.ingredients.add(i)
r.save()
class Migration(migrations.Migration):
dependencies = [
('cookbook', '0058_auto_20200625_2128'),
]
operations = [
migrations.RunPython(migrate_ingredients),
]