Multiple USERNAME_FIELD in django user model

后端 未结 5 1887
清歌不尽
清歌不尽 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:13

    Unfortunately, not out-of-the box.

    The auth contrib module asserts that the USERNAME_FIELD value is mono-valued.

    See https://github.com/django/django/search?q=USERNAME_FIELD

    If you want to have a multi-valued USERNAME_FIELD, you will either have to write the corresponding logic or to find a package that allow it.

提交回复
热议问题