Can I change the USERNAME_FIELD in Django 1.5 without creating a custom user?

前端 未结 2 957
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-04 20:08

I am trying to use the email field in the default Django user model as the username. I am using Django 1.5 and I saw that the default user has a USERNAME_FIELD

2条回答
  •  既然无缘
    2021-01-04 20:33

    You have to write a new Custom User Class by extending the AbstractBaseUser and not AbstractUser

    Declare your email as the USERNAME_FIELD there

    Optionally you can also declare a custom user manager that extends from BaseUserManager to handle the username required constraint. You can remove username from that manager's create_user function

提交回复
热议问题