Hi,
I was working on a project where I need to use Django auth with the custom user model using AbstractBaseUser
class CustomUser(AbstractBaseUser):
email = models.EmailField(unique=True)
is_active = models.BooleanField(default=True)
is_staff = models.BooleanField(default=False)
objects = CustomUserManager()
USERNAME_FIELD = 'email'
But I also don’t want to use inbuild groups & permissions table
I need to create my groups/roles & permissions, so I made something like as below.
class Role(models.Model):
name = models.CharField(max_length=100, unique=True)
class Permission(models.Model):
name = models.CharField(max_length=100, unique=True)
class RolePermission(models.Model):
role_id = models.IntegerField()
permission_id = models.IntegerField()
How do I create my own Role & Permission Table with my custom user model and implement other features in the permission with custom context_processor? and other functions?
Similar: custom django-user object has no attribute 'has_module_perms' - Stack Overflow , if you could give some code it would be helpful
Where I don’t want to use inbuild permissions with PermissionsMixin
!
And also need an admin portal how we register these custom user, custom permissions & custom role models?
or how can I remove the default adding permissions in Django for each model?
Note: I have tried this Customizing authentication in Django | Django documentation | Django
But it threw error when I tried to access /admin portal - ‘CustomUser’ object has no attribute ‘get_permissions’