Alami
Alami

Reputation: 45

use django-guardian with Custom User

I use custom user And i want to django-guardian to handle the permissions and groups. How i can do that my user:

class ProfileUser(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(_('email address'), unique=True)
    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    date_joined = models.DateTimeField(default=timezone.now)
    username = models.CharField(max_length=255,unique=True)
    first_name=models.CharField(max_length=255)
    last_name= models.CharField(max_length=255)
    departement= models.CharField(max_length=255)


    USERNAME_FIELD = 'username'
    REQUIRED_FIELDS = []

Upvotes: 0

Views: 213

Answers (1)

martin
martin

Reputation: 885

Just add a OneToOne field in the ProfileUser model that points to an actual user or use any other method included in the django documentation about extending the user model.

Upvotes: 1

Related Questions