{{{
from django.contrib.auth.base_user import AbstractBaseUser
class UserManager(BaseUserManager):
def _create_user(self, portal_user_id, email, **extra_fields):
del extra_fields['password'] <<-- trick to fix errror
email = self.normalize_email(email)
user = self.model(portal_user_id=portal_user_id, email=email,
**extra_fields)
user.save(using=self._db)
return user
def create_superuser(self, portal_user_id, email=None,
**extra_fields):
return self._create_user(portal_user_id, email, **extra_fields)
class User(AbstractBaseUser):
password = None
last_login = None
objects = UserManager()
...
}}}
command ./manage.py createsuperuser --email=m...@me.com should not ask
password if settings.AUTH_USER_MODEL does not have a password
command ./manage.py createsuperuser --email=m...@me.com --noinput should
not pass a password to create_superuser method
Traceback
{{{
Traceback (most recent call last):
File "./manage.py", line 15, in <module>
execute_from_command_line(sys.argv)
File "/app/.venv/lib/python3.7/site-
packages/django/core/management/__init__.py", line 371, in
execute_from_command_line
utility.execute()
File "/app/.venv/lib/python3.7/site-
packages/django/core/management/__init__.py", line 365, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/app/.venv/lib/python3.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **cmd_options)
File "/app/.venv/lib/python3.7/site-
packages/django/contrib/auth/management/commands/createsuperuser.py", line
59, in execute
return super().execute(*args, **options)
File "/app/.venv/lib/python3.7/site-
packages/django/core/management/base.py", line 335, in execute
output = self.handle(*args, **options)
File "/app/.venv/lib/python3.7/site-
packages/django/contrib/auth/management/commands/createsuperuser.py", line
179, in handle
self.UserModel._default_manager.db_manager(database).create_superuser(**user_data)
File "/app/trc/users/models.py", line 17, in create_superuser
return self._create_user(portal_user_id, email, **extra_fields)
File "/app/trc/users/models.py", line 12, in _create_user
user = self.model(portal_user_id=portal_user_id, email=email,
**extra_fields)
File "/app/.venv/lib/python3.7/site-packages/django/db/models/base.py",
line 495, in __init__
raise TypeError("'%s' is an invalid keyword argument for this
function" % kwarg)
TypeError: 'password' is an invalid keyword argument for this function
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29616>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* type: New feature => Cleanup/optimization
* stage: Unreviewed => Accepted
--
Ticket URL: <https://code.djangoproject.com/ticket/29616#comment:1>
* status: new => assigned
* owner: nobody => oliver
--
Ticket URL: <https://code.djangoproject.com/ticket/29616#comment:2>
* owner: oliver => (none)
* status: assigned => new
--
Ticket URL: <https://code.djangoproject.com/ticket/29616#comment:3>
* status: new => assigned
* owner: nobody => Josh Schneier
--
Ticket URL: <https://code.djangoproject.com/ticket/29616#comment:2>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
Comment:
[https://github.com/django/django/pull/10269 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/29616#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"8b43e9b1af37ab222cbe2964ae13a9203afb9c92" 8b43e9b]:
{{{
#!CommitTicketReference repository=""
revision="8b43e9b1af37ab222cbe2964ae13a9203afb9c92"
Fixed #29616 -- Fixed createsuperuser for user models that don't have a
password field.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29616#comment:4>