cook: allow setting first and last names of superusers (#21889)

This commit is contained in:
Frédéric Péters 2018-02-15 14:07:53 +01:00
parent c1768632e1
commit cc724cfc87
1 changed files with 4 additions and 1 deletions

View File

@ -137,10 +137,13 @@ class Command(BaseCommand):
connection.set_tenant(tenant)
def create_superuser(self, username='admin', email='admin@localhost', password=None):
def create_superuser(self, username='admin', email='admin@localhost',
first_name='Admin', last_name='', password=None):
user, created = User.objects.get_or_create(
username=username, email=email, is_superuser=True)
if created:
user.first_name = first_name
user.last_name = last_name
password = password or User.objects.make_random_password(length=30)
if password:
user.set_password(password)