from __future__ import unicode_literals

from django.db import models, migrations

def create_facilitators_group(apps, schema_editor):
    Group = apps.get_model("auth", "Group")
    group = Group(name="facilitators")
    group.save()


class Migration(migrations.Migration):

    dependencies = [
        ('studygroups', '0033_auto_20150826_1408'),
    ]

    operations = [
        migrations.RunPython(create_facilitators_group),
    ]

from __future__ import unicode_literals

from django.db import models, migrations

def create_facilitators_group(apps, schema_editor):
    Group = apps.get_model("auth", "Group")
    Group.objects.get_or_create(name="facilitators")


class Migration(migrations.Migration):

    dependencies = [
        ('studygroups', '0033_auto_20150826_1408'),
    ]

    operations = [
        migrations.RunPython(create_facilitators_group),
    ]

Change data migration to work even if facilitator group already exists
Change data migration to work even if facilitator group already exists

  from __future__ import unicode_literals
  
  from django.db import models, migrations
  
  def create_facilitators_group(apps, schema_editor):
      Group = apps.get_model("auth", "Group")
+     Group.objects.get_or_create(name="facilitators")
-     group = Group(name="facilitators")
-     group.save()
  
  
  class Migration(migrations.Migration):
  
      dependencies = [
          ('studygroups', '0033_auto_20150826_1408'),
      ]
  
      operations = [
          migrations.RunPython(create_facilitators_group),
      ]
  
Change data migration to work even if facilitator group already exists
## Code Before:
from __future__ import unicode_literals

from django.db import models, migrations

def create_facilitators_group(apps, schema_editor):
    Group = apps.get_model("auth", "Group")
    group = Group(name="facilitators")
    group.save()


class Migration(migrations.Migration):

    dependencies = [
        ('studygroups', '0033_auto_20150826_1408'),
    ]

    operations = [
        migrations.RunPython(create_facilitators_group),
    ]

## Instruction:
Change data migration to work even if facilitator group already exists
## Code After:
from __future__ import unicode_literals

from django.db import models, migrations

def create_facilitators_group(apps, schema_editor):
    Group = apps.get_model("auth", "Group")
    Group.objects.get_or_create(name="facilitators")


class Migration(migrations.Migration):

    dependencies = [
        ('studygroups', '0033_auto_20150826_1408'),
    ]

    operations = [
        migrations.RunPython(create_facilitators_group),
    ]
