gestioCOF/kfet/auth/migrations/0003_existing_groups.py

22 lines
574 B
Python
Raw Normal View History

2020-08-03 19:04:36 +02:00
# Generated by Django 2.2.8 on 2020-01-08 21:04
from django.db import migrations
def existing_groups(apps, schema_editor):
Group = apps.get_model("auth", "Group")
KFetGroup = apps.get_model("kfetauth", "KFetGroup")
for group in Group.objects.filter(name__icontains="K-Fêt"):
kf_group = KFetGroup(group_ptr=group, pk=group.pk, name=group.name)
kf_group.save()
class Migration(migrations.Migration):
dependencies = [
("kfetauth", "0002_kfetgroup_kfetpermission"),
]
operations = [migrations.RunPython(existing_groups)]