Django custom user model stores password in separate table — request.user causes "column users.password does not exist" error

i have created custom user in django class User(AbstractBaseUser, PermissionsMixin): which have password in user_credential table separately . what i want to request.user function i get error like

ProgrammingError at /api/planer/user/
column users.password does not exist
LINE 1: SELECT "users"."id", "users"."password", 

Ensured my custom authentication backend returns the correct user

Confirmed AUTHENTICATION_BACKENDS is set properly

Verified the User model has no password field

You need to "kick out" password (and probably last_login) from the model, since you inherited that from the AbstractBaseUser. Indeed:

class AbstractBaseUser(models.Model):
    password = models.CharField(_("password"), max_length=128)
    last_login = models.DateTimeField(_("last login"), blank=True, null=True)

so we can unset these with:

class User(AbstractBaseUser, PermissionsMixin):
    password = None
    last_login = None
Back to Top