To add a group from the API, you can do this: from django.contrib.auth.models import User,Group
# Get or Create the Group (I <3 this method) mygroup, created = Group.objects.get_or_create(name='Web Design') # Add fakeuser to group myuser = User.objects.get(username='fakeuser') myuser.groups.add(mygroup) Matt On Tue, Mar 2, 2010 at 2:07 AM, b14ck <rdeg...@gmail.com> wrote: > Hi everyone, > > I'm relatively new to Django, and I'm building a site which needs to > have multiple permission levels and groups. My experience with > django.contrib.auth at this point is decent. > > What I'm trying to do is create a group for each service that my > company offers. For example: > > - Conferencing > - Web Design > - Image Creation > > (Just picking random things.) But anyhow, I can't figure out how to do > this. > > The django.contrib.auth documentation shows the following group > information: > > User objects have two many-to-many fields: models.User. groups and > user_permissions. User objects can access their related objects in the > same way as any other Django model: > > myuser.groups = [group_list] > myuser.groups.add(group, group, ...) > myuser.groups.remove(group, group, ...) > myuser.groups.clear() > myuser.user_permissions = [permission_list] > myuser.user_permissions.add(permission, permission, ...) > myuser.user_permissions.remove(permission, permission, ...) > myuser.user_permissions.clear() > > But I'm unclear on how to actually great a group object which I can > then add to my user's groups list. > > Eventually I'll also want to create individual permissions (like > can_edit_page, etc.) but I'll work on that once I've got groups going. > > Thanks so much for your time, I really appreciate it. I've spent a > while looking for the information but I think I'm missing something > obvious. > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.