Currently trying to migrate two fields of information into one field. We have many, many objects to go through and it takes roughly 12 minutes to loop through all the objects. That would mean the website would be down for 12 minutes and we do not want that. Is there any way to speed up this migration? It works, it's just slow.
from __future__ import unicode_literals from django.db import migrations, models def set_people(apps, schema_editor): ParticipationCount = apps.get_model('partcount', 'ParticipationCount') for row in ParticipationCount.objects.all(): row.people = row.male + row.female row.save() class Migration(migrations.Migration): dependencies = [ ('partcount', '0002_participationcount_people'), ] operations = [ migrations.RunPython(set_people), ]
No is an acceptable answer in this case, I am just curious if there is a different way to do this, as loops can be slow. I am using Django 1.8 and python 2.