skillbox/server/portfolio/migrations/0006_auto_20210810_1348.py

28 lines
781 B
Python

# Generated by Django 2.2.22 on 2021-08-10 13:48
from django.db import migrations
def set_default_school_class(apps, schema_editor):
Project = apps.get_model('portfolio', 'Project')
projects = Project.objects.all()
bulk_projects = []
for project in projects:
owner = project.student
selected_class = owner.selected_class
if selected_class is not None:
project.school_class = selected_class
bulk_projects.append(project)
Project.objects.bulk_update(bulk_projects, ['school_class'])
class Migration(migrations.Migration):
dependencies = [
('portfolio', '0005_project_school_class'),
]
operations = [
migrations.RunPython(set_default_school_class, migrations.RunPython.noop)
]