[Solved]-Extend django Groups and Permissions

6👍

You need to make group names unique. So one way that you found out is having another name field, making it unique for all subgroups.

Another way would be to make use of existing name field and add special chars of yours. For example group name with admin#project1, members#project1 etc. (Note: I’m not sure ‘#’ is allowed in group name, you can choose any special character that is allowed).

So whenever you create Team you update the name field with suffix #<project_name> in Team models save() method.

To display it more sanely, you can add __unicode__() method to return only first part of the group name. Example:

class Team(Group):
    ...
    def __unicode__(self):
        try:
            return self.name.split('#')[0]
        except:
            #something wrong!
            return self.name
👤Rohan

Leave a comment