How to split django groups into subsets

I need to split django groups into logical subsets in order to distinguish the ones that I use for administration from the others (such as standard groups and so on).

Reading the code I found that django Group model has only two fields: name and permissions.

I'd like to do something like:


and so on. Is there any built-in function to do that or I'll have to subclass the Group model on my own and add a type field?

Any other suggestion is well accepted!


Instead of subclassing groups, I recommend adding a GroupType model that will have a many to many relation to group. Something like this:

class GroupType(models.Model):
    name = models.CharField(max_length=128)
    groups = models.ManyToManyField('auth.Group', related_name='groups' )

Now, if you want to add a group to a specific type you can just do a

group = Group.get(...)
group_type = GroupType.objects.get(name='group_type_1')

I'm aware that the above is not perfect from a design point of view, since you allow groups to belong to more than one type (of course depending on your requirement this may actually be needed) but you don't mess at all with the stock Django groups. You can easily enforce only one GroupType per Group by using the m2m-changed signal ( Check if action is pre_add and, if there are more than one members to this relation throw a ValidationError

Need Your Help

Ajax Submit using PHP and mysql

php mysql jquery

There are may button son php page. I want to submit value of button and the delete record from table using that value. Ajaxz code is

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.