I have the following user model,
class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(unique=True, max_length=255)
mobile = PhoneNumberField(null=True)
username = models.CharField(null=False, unique=True, max_length=255)
full_name = models.CharField(max_length=255, blank=True, null=True)
is_bot = models.BooleanField(default=False)
I want to create a custom command which could work like createsuperuser and creates a bot.
I have created a management package in the relevant app and added a command package inside that and a file createbot.py inside of that.
This is my code inside createbot.py
class Command(BaseCommand):
def handle(self, email, username=None, password=None):
user = User.objects.create(email,
username=username,
password=password,
is_staff=True,
is_superuser=True,
is_active=True,
is_bot=True
)
self.stdout.write(self.style.SUCCESS('Successfully create user bot with id: {}, email: {}'.format(user.id, user.email)))
I want this to work exactly like createsuper user giving me prompts to enter email, name and the works. But when I run it, I get the following,
TypeError: handle() got an unexpected keyword argument 'verbosity'
How can I get this to work?