Hi,
I have created custom user model extending AbsractBaseUser class. I have specified email field as the USERNAME_FIELD. But when I create an instance of this model and save it to the database, Django is only asking for the field which has been defined as foreign key and not asking email field to input. Is this the expected behavior? Where am I going wrong? I’m using Django shell to creating and saving a model instance.
Below is the model defined:
class UserProfile(AbstractBaseUser):
id = models.UUIDField(default=uuid.uuid4, unique=True, primary_key=True,
editable=False)
first_name = models.CharField("first name", max_length=150, blank=True)
last_name = models.CharField("last name", max_length=150, blank=True)
email = models.EmailField(_("email address"), unique=True,
error_messages={"unique": _("A user with that email address already
exists!")})
role = models.ForeignKey("Role", on_delete=models.CASCADE)
objects = UserManager()
USERNAME_FIELD = "email"
Any help is much appreciated