Multiple USERNAME_FIELD in django user model

后端 未结 5 1890
清歌不尽
清歌不尽 2020-12-16 02:22

My custom user model:

class MyUser(AbstractBaseUser):
    username = models.CharField(unique=True,max_length=30)
    email = models.EmailField(unique=True,ma         


        
5条回答
  •  被撕碎了的回忆
    2020-12-16 03:03

    If your USERNAME_FIELD is username and the user logs in with email, maybe you can write a code that fetches the username using the provided email and then use that username along with the password to authenticate.

提交回复
热议问题