[Django] #35287: manage createsuperuser too restrictive

8 views
Skip to first unread message

Django

unread,
Mar 11, 2024, 1:08:04 AM3/11/24
to django-...@googlegroups.com
#35287: manage createsuperuser too restrictive
-------------------------------------+-------------------------------------
Reporter: Matthew | Owner: nobody
Pava |
Type: Bug | Status: new
Component: Core | Version: 5.0
(Management commands) | Keywords: createsuperuser
Severity: Normal | username
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
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.
--
Ticket URL: <https://code.djangoproject.com/ticket/35287>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Mar 11, 2024, 1:23:19 AM3/11/24
to django-...@googlegroups.com
#35287: manage createsuperuser too restrictive
-------------------------------------+-------------------------------------
Reporter: Matthew Pava | Owner: nobody
Type: Bug | Status: closed
Component: Core (Management | Version: 5.0
commands) |
Severity: Normal | Resolution: duplicate
Keywords: createsuperuser | Triage Stage:
username | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Mariusz Felisiak):

* resolution: => duplicate
* status: new => closed

Comment:

Duplicate of #26412.
--
Ticket URL: <https://code.djangoproject.com/ticket/35287#comment:1>
Reply all
Reply to author
Forward
0 new messages