django 1.7 Groups

48 views
Skip to first unread message

John Rodkey

unread,
Sep 12, 2014, 2:49:40 PM9/12/14
to django...@googlegroups.com
How can I modify the auto generated auth groups to include a foreign key? We wish to add a foreign key to show group ownership to a company table.

For example, Company A could create a librarians group and assign users.

Company B could create a brokers group and assign users

ma...@tubeards.com

unread,
Sep 15, 2014, 8:09:59 AM9/15/14
to django...@googlegroups.com
Hi,

changing the base Group model is not very easy.

My suggestion is to create a ManyToMany relation on your Company model.

class Company(models.Model):
    ....
    groups = models.ManyToManyField("auth.Group")

The design allows in theory many companies to have the same group, but this you can check on code side.

Cheers

John Rodkey

unread,
Sep 15, 2014, 12:09:28 PM9/15/14
to django...@googlegroups.com
I just thought of this this morning too. Thanks for the recommendation
Reply all
Reply to author
Forward
0 new messages