0

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 = []
minglyu
  • 2,958
  • 2
  • 13
  • 32
Alami
  • 45
  • 1
  • 6

1 Answers1

1

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.

martin
  • 887
  • 7
  • 23
  • Thank you for your reply, have you an example to how use OneToOne field ? – Alami Jun 27 '20 at 00:45
  • is a normal, django field. Use it just like the ForeignKey: `myfield = models.OneToOneField(Model, on_delete=models.CASCADE)` – martin Jun 27 '20 at 02:51