You can easily create a group by doing the following:
from django.contrib.auth.models import Group
newgroup = Group.objects.create(name=course.name)
You can put this code in your models like this (or maybe create a custom model manager):
from django.contrib.auth.models import User, Group
class Course(models.Model):
name = models.CharField(max_length=100)
@classmethod
def create(course, name):
newcourse = course(title=name)
# create the group for the course
newgroup = Group.objects.create(name=newcourse.name)
return newcourse
Then, you can create your course:
course = Course.create(name="Django: The Web framework for perfectionists with deadlines")