[Django]-Django create_superuser() missing 1 required positional argument: 'username'

2👍

Welcome to SO, @Omkar.

You just need to change the fields REQUIRED_FIELD to REQUIRED_FIELDS.

REQUIRED_FIELDS = ['username']

You can check it on the docs.

2👍

@Omkar Kale, Please look your method:

def create_superuser(self, email, username, password):
    user = self.create_user(
        email=self.normalize_email(email),
        password=password,
        username=username,
    )

Please change it:

 def create_superuser(self, username, email, password):

    user = self.create_user(
        username=username,
        email=self.normalize_email(email),
        password=password,

        )

Look, you need to pass value according to the parameter. So

  • first: username,
  • second: email
  • third password.

Then you will no longer going to receive error for positional argument. you have to pass them according to the position of the parameter.

Leave a comment