view中导入:from django.contrib.auth.models import AbstractBaseUser
settings.py中设置了:AUTH_USER_MODEL='app名.model自定义类'
解决方法:在自定义类中加:
identifier = models.CharField(max_length=40, unique=True)
USERNAME_FIELD = 'identifier'
view中导入from django.contrib.auth.models import AbstractUser 则不会出现该问题