0017_groups.py 543 Bytes
Newer Older
1
2
3
from django.db import migrations
from django.contrib.auth.models import Group

4
groups = ['Jedi', 'Padawan', 'Droid']
5

6
def add_groups(apps, schema_editor):
7
8
9
10
11
    for i in groups:
        group = Group(name=i)
        group.save()

def remove_groups(apps, schema_editor):
12
13
    for i in groups:
        Group.objects.filter(name=i).delete()
14
15
16
17
18
19
20
21
22
23
24


class Migration(migrations.Migration):

    dependencies = [
        ('rp', '0016_auto_20170617_0929'),
    ]

    operations = [
        migrations.RunPython(add_groups, reverse_code=remove_groups),
    ]