superuser

How to override createsuperuser command in django

How to override createsuperuser command in django Question: I’m trying to customize the createsuperuser command. The purpose of this is: I’ve a table called administrator, and its have OneToOne relationship with auth_user table class Administrator(models.Model): user = models.OneToOneField(get_user_model(), on_delete=models.CASCADE, related_name="admin") And whenever I create new super user by using command createsuperuser, i’d like to create …

Total answers: 1

Can't set user.is_active and user.is_admin to True

Can't set user.is_active and user.is_admin to True Question: I need to use email for authentication instead of user but when ever I create super user it doesn’t set the is_active and is_admin to True which are False by default! models.py class CustomUserManager(BaseUserManager): def create_user(self, email, username, password=None): if not email: raise ValueError(‘User must have an …

Total answers: 1