I have created a superuser in my django project that access to all of the permissions of the admin page. The problem is that when I add an object to the customized user model and set is_staff = true for that new user and then logout from the admin, I cannot login with the staff user account due to the error that says “please enter correct username and password for the staff account” despite the matter that the username and password of that staff user are right.
I will thank if anyone help me to solve this problem
CodePudding user response:
Here is my custom user model.
class User(AbstractUser):
pass
class Meta:
verbose_name = _('کاربر')
verbose_name_plural = _('کاربر')
def __str__(self):
return f"{self.first_name} {self.last_name}"
CodePudding user response:
Have you told your django app that this user class is your user model?
To do so, you need to set AUTH_USER_MODEL
in your app's settings. This is described in more detail here in the Django documentation.