Django CustomUser
I extended default User
model as follow:
class CustomUser(AbstractUser):
email = models.EmailField(_('email address'), unique=True)
first_name = models.CharField(max_length = 100, blank = False)
last_name = models.CharField(max_length = 100, blank = False)
...
USERNAME_FIELD = 'email'
EMAIL_FIELD = 'email'
REQUIRED_FIELDS = ['first_name', 'last_name', 'username','password']
Now when creating a new superuser the prompt for password is not hidden
$ python manage.py createsuperuser
Email address: user1@coolapp.com
First name: John
Last name: Smith
Username: cool_username
Password: fancy_p4$$w0rd
Superuser created successfully.
Is there any way it can be hidden?
SOLUTION:
When defining REQUIRED_FIELDS
in CustomUser model just skip password. The default password prompt will show up after the list is iterated completly:
REQUIRED_FIELDS = ['first_name', 'last_name', 'username', 'is_teacher']
Creating new superuser:
$ python manage.py createsuperuser
Email address: user1@coolapp.com
First name: John
Last name: Smith
Username: cool_username
Is teacher: True
Password:
Password (again):
Superuser created successfully.