From c215ad9d0fdcb8d83472d8b06f4f342be253f07d Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sat, 30 Oct 2021 10:47:44 -0700 Subject: [PATCH] Ensure overridden Sleep.save() is run on migration --- core/migrations/0015_add_nap_field_for_sleep.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/migrations/0015_add_nap_field_for_sleep.py b/core/migrations/0015_add_nap_field_for_sleep.py index aee3f332..c63f3a33 100644 --- a/core/migrations/0015_add_nap_field_for_sleep.py +++ b/core/migrations/0015_add_nap_field_for_sleep.py @@ -2,9 +2,9 @@ from django.db import migrations, models def set_napping(apps, schema_editor): - Sleeps = apps.get_model('core', 'Sleep') - for sleep in Sleeps.objects.all(): - sleep.napping = sleep.nap + # The model must be imported to ensure its overridden `save` method is run. + from core import models + for sleep in models.Sleep.objects.all(): sleep.save()