Ensure overridden Sleep.save() is run on migration

This commit is contained in:
Christopher C. Wells 2021-10-30 10:47:44 -07:00
parent 124355ebb5
commit c215ad9d0f
1 changed files with 3 additions and 3 deletions

View File

@ -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()