from django.db import migrations def migrate_titles(apps, schema_editor): ObjectiveGroup = apps.get_model('objectives', 'ObjectiveGroup') for og in ObjectiveGroup.objects.filter(title='Sprache und Kommunikation'): og.title = 'language_communication' og.save() for og in ObjectiveGroup.objects.filter(title='Gesellschaft'): og.title = 'society' og.save() class Migration(migrations.Migration): dependencies = [ ('objectives', '0004_auto_20181030_1726') ] operations = [ migrations.RunPython(migrate_titles) ]