Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class UserManager(BaseUserManager):
- def _create_user(self, username, email, password, is_active, is_staff, is_superuser, **extra_fields):
- if not email:
- return ValueError('El email es un campo obligatorio')
- email = self.normalize_email(email)
- user = self.model(username=username, email=email, is_active=is_active, is_staff=is_staff, is_superuser=is_superuser, **extra_fields)
- user.set_password(password)
- user.save(using = self._db)
- return user
- def create_user(self, username, email, password=None, **extra_fields):
- return self._create_user(username, email, password, False, False, False, **extra_fields)
- def create_superuser(self, username, email, password, **extra_fields):
- return self._create_user(username, email, password, True, True, True, **extra_fields)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement