I'm trying to extend the django Group model to make it friendlier for multi tenancy. Basically I want to remove the unique constraint on the name
field, add a field called tenant
, and make name
and tenant
unique together. So far I can do all of that but I can't create the unique_together
constraint.
Here's what I have so far:
from django.contrib.auth.models import Group
Group._meta.get_field('name')._unique = False
Group.add_to_class('tenant', models.ForeignKey(blah blah blah))
Now how would I create the unique_together
constraint?