I can't use two models that extend abstractuser

I’m using django allauth, and I have two models that inherit from abstractuser.

class CustomUser(AbstractUser):
    email = models.EmailField(unique=True)
    phone = models.CharField(max_length=20)
    indication = models.CharField(max_length=150, blank=True, default="")

    USERNAME_FIELD = "email"
    REQUIRED_FIELDS = ["username", "phone"]

    def __str__(self):
        return self.first_name

class Employee(CustomUser):
    is_Barber = models.BooleanField(verbose_name="É um barbeiro?")
    branch = models.ForeignKey(Branch, on_delete=models.CASCADE, related_name="employee", null=True, blank=True, verbose_name='Filial')

    class Meta:
        verbose_name = "Funcionário"
        verbose_name_plural = "Funcionários"

I registered CustomUser in the settings:
AUTH_USER_MODEL = "core.CustomUser"

The Employee model works, except that I can’t log in with it.

I think it will be need add custom auth backend.

1 Like

That’s correct. Under no reasonable set of circumstances may you have two “User” models.

In your case, Employee is not a user model - it is a OneToOne profile with CustomUser. See the docs for Multi-table inheritance to see what you’ve actually created here.

So the “User” object needing to be logged in is still a CustomUser.

1 Like

thanks guys, it helped a lot