0009_auto_20151217_1633.py
833 Bytes
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
def init_pattern_genders(apps, schema_editor):
Pattern = apps.get_model('patterns', 'Pattern')
PatternType = apps.get_model('patterns', 'PatternType')
for pt in PatternType.objects.filter(inflection_type='subst'):
pt.genders = [g for g in pt.pattern_set.distinct().values_list(
'inflection__gender', flat=True) if g]
for p in Pattern.objects.filter(type__inflection_type='subst'):
p.genders = [g for g in p.inflection_set.distinct().values_list(
'gender', flat=True) if g]
class Migration(migrations.Migration):
dependencies = [
('patterns', '0008_auto_20151217_1521'),
]
operations = [
migrations.RunPython(init_pattern_genders),
]