# I get the following error when i try to create a new superuser from the command prompt in attempt to create a custom user model

**URL:** <https://forum.djangoproject.com/t/i-get-the-following-error-when-i-try-to-create-a-new-superuser-from-the-command-prompt-in-attempt-to-create-a-custom-user-model/23095>\
**Category:** Getting Started\
**Created:** [August 16, 2023, 8:49am UTC](https://forum.djangoproject.com/t/i-get-the-following-error-when-i-try-to-create-a-new-superuser-from-the-command-prompt-in-attempt-to-create-a-custom-user-model/23095 "2023-08-16T08:49:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Emilio-Maingi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/emilio-maingi/32/15393_2.png) [@Emilio-Maingi](https://forum.djangoproject.com/u/Emilio-Maingi)\
**Post date:** [August 16, 2023, 8:49am UTC](https://forum.djangoproject.com/t/i-get-the-following-error-when-i-try-to-create-a-new-superuser-from-the-command-prompt-in-attempt-to-create-a-custom-user-model/23095/1 "2023-08-16T08:49:32Z")

</div>

TypeError: UserManager.create\_superuser() missing 4 required positional arguments: ‘user\_name’, ‘first\_name’, ‘last\_name’, and ‘phone\_number’

This is the error i get when i run ‘python manage.py createsuperuser’ even though i have specified the arguments in the REQUIRED\_FIELDS, the command prompt does not give me an option to enter the username firstname, last name and phonenumber. I have seen that many people have asked the same question in different forums, i have tried the different solutions provided but i have not been successful. Kindly help if you can. The following is my code in models.py

```auto
from django.db import models
from django.contrib.auth.models import AbstractBaseUser, PermissionsMixin, BaseUserManager

    

class UserManager(BaseUserManager):
    def create_user(
        self, 
        email,
        user_name, 
        first_name, 
        last_name, 
        phone_number, 
        password,
        **other_fields
        ):
        
        if not email:
            raise ValueError('User must have an email address')
        if not user_name:
            raise ValueError('User must have a username')
        
       
        email = self.normalize_email(email),

        user = self.model(
            email=email, 
            user_name=user_name, 
            first_name=first_name, 
            last_name=last_name, 
            phone_number=phone_number,
            **other_fields
        )
        
        user.set_password(password)
        user.save(using=self._db)
        
        return user
    
    def create_superuser(
        self, 
        email,
        user_name, 
        first_name, 
        last_name, 
        phone_number, 
        password,
        **other_fields
        ):
        
        if other_fields.get('is_staff') is not True:
            raise ValueError('Super User must be a staff')
        if other_fields.get('is_superuser') is not True:
            raise ValueError('Super User must be a superuser')
        
        other_fields.setdefault('is_staff', True)
        other_fields.setdefault('is_superuser', True)
        other_fields.setdefault('is_admin', True)
        other_fields.setdefault('is_active', True)
        
        return self.create_user(
            self, 
            email, 
            user_name, 
            first_name, 
            last_name, 
            phone_number, 
            password, 
            **other_fields
        )

class User(AbstractBaseUser, PermissionsMixin):
    email = models.EmailField(max_length=150, unique = True, blank=True)
    user_name = models.CharField(max_length=50, unique = True)
    first_name = models.CharField(max_length=50, blank=True)
    last_name = models.CharField(max_length=50, blank=True)
    phone_number = models.CharField(max_length=30, blank=True)
    
    
    date_joined = models.DateTimeField(auto_now_add=True)
    last_login = models.DateTimeField(auto_now_add=True)
    is_admin = models.BooleanField(default=False)
    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=False)
    is_superuser = models.BooleanField(default=False)
    
    objects = UserManager()
    
   
    
    USERNAME_FIELD = 'email'
    RUQUIRED_FIELDS = [
        'user_name', 
        'first_name', 
        'last_name', 
        'phone_number'
    ]
    
    
    def __str__ (self):
        return self.email
 

```

in the settings.py i have the following also

```auto
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',    
    'users',
]

AUTH_USER_MODEL = 'users.User'

```

This is the full error log:

```auto
Traceback (most recent call last):
  File "D:\Dev\sixteen\liquormatic\manage.py", line 22, in <module>
    main()
  File "D:\Dev\sixteen\liquormatic\manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "D:\Dev\sixteen\Lib\site-packages\django\core\management\ __init__.py", line 442, in execute_from_command_line
    utility.execute()
  File "D:\Dev\sixteen\Lib\site-packages\django\core\management\ __init__.py", line 436, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "D:\Dev\sixteen\Lib\site-packages\django\core\management\base.py", line 412, in run_from_argv
    self.execute(*args, **cmd_options)
  File "D:\Dev\sixteen\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 88, in execute
    return super().execute(*args, **options)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\sixteen\Lib\site-packages\django\core\management\base.py", line 458, in execute
    output = self.handle(*args, **options)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "D:\Dev\sixteen\Lib\site-packages\django\contrib\auth\management\commands\createsuperuser.py", line 233, in handle
    self.UserModel._default_manager.db_manager(database).create_superuser(
TypeError: UserManager.create_superuser() missing 4 required positional arguments: 'user_name', 'first_name', 'last_name', and 'phone_number'

(sixteen) D:\Dev\sixteen\liquormatic>

```

---

<div class="post-metadata">

**Author:** ![addwebsolution](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/addwebsolution/32/23762_2.png) [@addwebsolution](https://forum.djangoproject.com/u/addwebsolution)\
**Post date:** [August 16, 2023, 9:21am UTC](https://forum.djangoproject.com/t/i-get-the-following-error-when-i-try-to-create-a-new-superuser-from-the-command-prompt-in-attempt-to-create-a-custom-user-model/23095/2 "2023-08-16T09:21:58Z")

</div>

In User Model spelling of `REQUIRED_FIELDS` is wrong

> [@Emilio-Maingi](#):
>
> ```auto
> RUQUIRED_FIELDS = [
> 'user_name', 
> 'first_name', 
> 'last_name', 
> 'phone_number'
> ]
> 
> ```

---

<div class="post-metadata">

**Author:** ![Emilio-Maingi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/emilio-maingi/32/15393_2.png) [@Emilio-Maingi](https://forum.djangoproject.com/u/Emilio-Maingi)\
**Post date:** [August 16, 2023, 9:26am UTC](https://forum.djangoproject.com/t/i-get-the-following-error-when-i-try-to-create-a-new-superuser-from-the-command-prompt-in-attempt-to-create-a-custom-user-model/23095/3 "2023-08-16T09:26:17Z")

</div>

oooh yeah. so careless of me… Thanks so much
