pythondjango-admindjango-authenticationdjango-users

Problems logging in with email in Django admin


I have followed a tutorial to enable user login in django through mail, but after doing it and having the app running, the logind admin view does not recognize my username and/or password, I leave an example:

enter image description here

User Model:

class User(AbstractUser):
    email = models.EmailField("email", unique=True)
    create_date = models.DateField(auto_now_add=True)
    type_plan = models.ForeignKey(Plan, on_delete=models.SET_DEFAULT, default=1)
    phase_plan = models.IntegerField(default=0)
    is_active = models.BooleanField(default=False)

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

Settings:

AUTH_USER_MODEL = "user.User"

The server runs fine, and the superuser creation works, and it persists in the database correctly. However, I always get the error that it is being entered incorrectly,.

I have done the migrations correctly and I don't know why it throws me that error, but it is only when I want to log in with mail, if I remove that option and leave it by default it works.


Solution

  • Here I can see is_active field is Default False so, created user not is active

    so, you need set is_active default True

    is_active = models.BooleanField(default=True)