I'm trying to create group and add some permissions to it. This is what I did:
students = Group(name='Students')
students.save()
somemodel_ct = ContentType.objects.get(app_label='course', model='course')
can_view = Permission(name='Can View', codename='can_view_something',
content_type=somemodel_ct)
can_view.save()
can_modify = Permission(name='Can Modify', codename='can_modify_something',
content_type=somemodel_ct)
can_create = Permission(name='Can Create', codename='can_create_something',
content_type=somemodel_ct)
can_delete = Permission(name='Can Delete', codename='can_delete_something',
content_type=somemodel_ct)
can_delete.save()
But this seems ugly to me, is there other way (except going to admin page which I would like to avoid)