I have custom user model and I specified email as USERNAME_FIELD there:
class User(AbstractBaseUser, PermissionsMixin):
username = models.CharField(max_length=50, unique=True, verbose_name=_('Username'))
...
USERNAME_FIELD = 'email'
Now when I create new user I get this error:
create_user() takes at least 3 arguments (2 given)
I found piece of code in storage/django_orm.py that replaces my email field with username field:
@classmethod
def create_user(cls, *args, **kwargs):
if 'username' in kwargs:
kwargs[cls.username_field()] = kwargs.pop('username')
return cls.user_model().objects.create_user(*args, **kwargs)
So, I think it would be better to at least check if cls.username_field() is not equal to "email":
if 'username' in kwargs and cls.username_field() != 'email':
kwargs[cls.username_field()] = kwargs.pop('username')
I have custom user model and I specified email as USERNAME_FIELD there:
Now when I create new user I get this error:
I found piece of code in storage/django_orm.py that replaces my email field with username field:
So, I think it would be better to at least check if cls.username_field() is not equal to "email":