Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

django custom user model groups and permissions

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:

admin screenshot

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.

like image 297
user3262515 Avatar asked Apr 10 '16 21:04

user3262515


1 Answers

Deleting this line in MyUserAdmin class fixed the problem up.

filter_horizontal = ()
like image 175
user3262515 Avatar answered Oct 08 '22 22:10

user3262515