Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: Integrate Permissions and Groups functionality into Custom User Model

Tags:

django

I have create a custom user model for my django apps. Now i want to use the django permissions and groups system. I made permission and groups but when i go to use them in my custom user model a take errors like

>>> john.groups.add(special_users)
Traceback (most recent call last):
  File "<console>", line 1, in <module>
AttributeError: 'MyCustomUserModel' object has no attribute 'groups'

I imagine that i have to put some extra code in my custom user model to integrate this functionality Could anyone help with this problem?

like image 539
Zakos Avatar asked Mar 21 '23 18:03

Zakos


1 Answers

Finally MyCustomUserModel had to inherit and from PermissionsMixin

class MyCustomUserModel(AbstractBaseUser,PermissionsMixin):
like image 114
Zakos Avatar answered Apr 27 '23 12:04

Zakos