Missing 1 required positional argument in django createsuperuser

i am trying to create an Account model that extends AbstractBaseUser and i am using a Accountmanger but it shows me the following error when i tried to create a superuser.

 AccountManager.create_superuser() missing 1 required positional argument: 'phone' 

and this is the Manager class

class AccountManager(BaseUserManager):
    def create_user(self, email,phone,password, **extra_fields):
        if not email:
            raise ValueError('The given email must be set')
        if not phone:
            raise ValueError('User must have a phone number.')
        account = self.model(
        extra_fields.setdefault('is_superuser', False)
        return account

    def create_superuser(self,email,phone,password,**extra_fields):
        extra_fields.setdefault('is_superuser', True)
        if extra_fields.get('is_superuser') is not True:
            raise ValueError('Superuser must have is_superuser=True.')
        if not phone:
            raise ValueError('User must have a phone number.')
        account = self.create_user(email,phone,password=password)
        return account

and here is the Model class

class Account(AbstractBaseUser, PermissionsMixin):
    name = models.CharField(max_length = 20,verbose_name = "Name",)
    email = models.CharField(max_length = 50, unique = True, validators [validators.EmailValidator()],verbose_name = "Email")
    phone = models.CharField(max_length=15,unique=True,null=True)
    date_joined = models.DateTimeField(default=timezone.now)
    picture = models.ImageField(upload_to='account/', blank=True, null=True)
    is_staff = models.BooleanField(default=False)
    is_active = models.BooleanField(default=True)
    admin = models.BooleanField(default=False) 
    USERNAME_FIELD = 'email'

    # Custom user manager
    objects = AccountManager()

    def __str__(self):
        return self.name

i have searched error like this but didn't work out ... help

Back to Top