Reputation: 173
I am trying to implement custom user model in my django application.
If I just copy and paste the code from this article, it works great. But I wish this custom user model to have permissions and groups. So I added this inheritance to models.py:
class MyUser(AbstractBaseUser, PermissionsMixin):
and these fields into the admin.py MyUserAdmin(UserAdmin) class:
('Permissions', {'fields': (
'is_admin', 'is_staff', 'is_active', 'groups', 'user_permissions',
)}),
But it looks strange for me:
As I know, it must be two containers: left (that I have) that shows all available groups and permissions and right (that I don't have) that shows all current user's groups and permissions.
P.S. I tried google for it and found only one post on reddit which is 10 month old but doesn't have a solution.
Upvotes: 6
Views: 3439
Reputation: 11
You must set argument in filter_horizontal(ARGUMENT)
,
the argument is your field manyToMany
in model
.
Example:
class CustomUser(PermissionsMixin, AbstractBaseUser):
custom_groups = models.ManyToManyField('CustomUserGroups', blank=True)
class CustomUserAdmin(UserAdmin):
filter_horizontal = ('custom_groups', )
Upvotes: 0
Reputation: 173
Deleting this line in MyUserAdmin class fixed the problem up.
filter_horizontal = ()
Upvotes: 5