Opened 12 months ago
Closed 12 months ago
#35287 closed Bug (duplicate)
manage createsuperuser too restrictive
Description ¶
I have a custom user model inheriting from AbstractUser
. I set username = None
because I don't care about usernames. I care about emails. Anyway, whenever I do that, I get an error message from the manage createsuperuser
command.
For example:
TypeError: UserManager.create_superuser() missing 1 required positional argument: 'username' ValueError: The given username must be set TypeError: StudentManager._create_user() takes from 1 to 3 positional arguments but 4 were given
This has forced me to customize the UserManager
:
class MyUserManager(UserManager): def _create_user(self, username=None, email=None, password=None, **extra_fields): email = self.normalize_email(email) user = self.model(email=email, **extra_fields) user.password = make_password(password) user.save(using=self._db) return user def create_superuser(self, email=None, password=None, **extra_fields): super().create_superuser(email, password, **extra_fields)
My rationale for not having or requiring a username is that all valid email addresses are unique. I think the createsuperuser
command ought to be more lenient in regard to the username
field.
Note:
See TracTickets
for help on using tickets.
Duplicate of #26412.