I initially extended only the Group model, and although I got the extra fields working correctly, I end up with inconsistent results when I switch back to the auth-user model:
group1 = MyGroup(..)
user = group1.user_set.all()[0]
group2 = user.groups.all()[0]
group1 == group2 #(False!)
type(group1) #MyGroup..
type(group2) #Group..
My next thought was to extend both the auth.User and auth.Group models.
Example structure:
from django.contrib.auth.models import User As DjangoUser
from django.contrib.auth.models import Group As DjangoGroup
class MyGroup(DjangoGroup):
extra1 = models.CharField(..)
class MyUser(DjangoUser):
extra1 = models.CharField(..)
Is this possible? I saw a bug-report stating it was fixed here. However I didn't see an example of the correct way to achieve this, nor was it clear if this portion was necessary post bug-fix:
manager = UserManager()
class MyUser(DjangoUser):
signature = forms.CharField()
post_count = forms.IntegerField()
objects = manager
_default_manager = manager
Any ideas/examples of this sort of behavior? I attempted to re-define the 'groups' link in the user model but that led to a validation error. Ideally I would like to be able to run the example above and have group1 == group2 and type(group2) == type(MyGroup())