def _create_user(self, username, password, **extra_fields): if not username: raise ValueError('The given username must be set') username = AbstractBaseUser.normalize_username(username) user = self.model(username=username, **extra_fields) user.set_password(password) user.save() return user
def create_user(self, username, password, **kwargs): if not username: raise ValueError("Account must have username") username = AbstractBaseUser.normalize_username(username) user = self.model(username=username, **kwargs) user.set_password(password) user.save() return user
def create_user(self, username, email=None, password=None, **kwargs): if not username: raise ValueError('User must have username') username = AbstractBaseUser.normalize_username(username) email = self.normalize_email(email) user = self.model(username=username, email=email, **kwargs) user.set_password(password) user.save() return user
def create_user(self, username, email, password=None): if not username: raise ValueError('Username required') if not email: raise ValueError('Email required') user = self.model( username=AbstractBaseUser.normalize_username(username), email=self.normalize_email(email)) user.set_password(password) user.save() return user
def validate_username(self, value): user = usr.objects.filter(username=value) if user: raise serializers.ValidationError("Username is already taken") return AbstractBaseUser.normalize_username(value)