from django.db import migrations EVENT_PATH = "polylan-43" def backfill_event(apps, schema_editor): Event = apps.get_model("events", "Event") SteamCollection = apps.get_model("opus_magnum", "SteamCollection") Submission = apps.get_model("opus_magnum", "Submission") event = Event.objects.get(path=EVENT_PATH) SteamCollection.objects.filter(event__isnull=True).update(event=event) Submission.objects.filter(event__isnull=True).update(event=event) def noop(apps, schema_editor): pass class Migration(migrations.Migration): dependencies = [ ("opus_magnum", "0016_steamcollection_event_submission_event"), ("events", "0002_seed_polylan_43"), ] operations = [ migrations.RunPython(backfill_event, noop), ]