Closed BoPeng closed 4 years ago
I did something like
class User(AbstractUser, MemberRelationsMixin):
class GroupsManagerMeta:
group_model = 'users.My_Group'
group_member_model = 'users.User'
class My_Group(GroupMixin):
pass
and everything seems to be working all right. I do not need to sync to User.groups
since I do not use guardian
so the above set up basically allows me to have every user being a Member
.
Hi Bo! Thank you for the solution you posted. I think it is a great solution the one you found. Glad it worked!
I will take time to test it and will add to the documentation as it seems a very handy use case.
Note that when I later tried to squash my migrations to the User
model I got some CircularDependencyError
because User
depends on groups-manager
and groups-manager
depends on User
. It is therefore recommended to migrate the bare User
without groups-manager
before adding the mixins, which was what I did initially.
My application has a customized
User
class derived fromAbstractUser
. Instead of defining separateMember
class andsync
orone to one
toUser
, I am wondering if it is more straightforward to doso that every user would automatically be a
Member
.I understand
MemberMixin
has some conflicting fields withAbstractUser
, so I was basically asking if it is ok to copy the code forMemberMixin
intoclass User
, and do something like