Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from django.contrib.auth.models import BaseUserManager
- class CreativeUserManager(BaseUserManager):
- def create_user(self, email, password=None, superuser=False):
- if not email:
- raise ValueError("User must have an email!")
- user = self.model(
- email=self.normalize_email(email)
- )
- user.set_password(password)
- if superuser:
- user.is_admin = True
- user.is_staff = True
- user.is_superuser = True
- user.save(using=self._db)
- return user
- def create_superuser(self, email, password):
- user = self.create_user(
- email,
- password,
- superuser=True
- )
- return user
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement