Create django groups with management command
from django.core.management.base import BaseCommand
from django.contrib.auth.models import Group
from django.conf import settings
class Command(BaseCommand):
help = 'Create django groups'
def handle(self, *args, **options):
'''
In django settings file create a GROUPS list for groups to be created
'''
groups = settings.GROUPS
for group in groups:
new_group, created = Group.objects.get_or_create(name=group)
self.stdout.write(self.style.SUCCESS('Groups {} installed'.format(
groups)))