Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class CustomUserManager(BaseUserManager):
- use_in_migrations = True
- def _create_user(self, email, password, **extra_fields):
- """
- Creates and saves a User with the given email and password.
- """
- print('creating user...')
- if not email:
- raise ValueError('Email must be set') #<--- Throws the error.
- email = self.normalize_email(email)
- user = self.model(email=email, **extra_fields)
- user.set_password(password)
- user.save(using=self._db)
- return user
- def create_user(self, email=None, password=None, **extra_fields):
- extra_fields.setdefault('is_staff', False)
- extra_fields.setdefault('is_superuser', False)
- return self._create_user(email, password, **extra_fields)
- def create_superuser(self, email, password, **extra_fields):
- extra_fields.setdefault('is_staff', True)
- extra_fields.setdefault('is_superuser', True)
- if extra_fields.get('is_staff') is not True:
- raise ValueError('Superuser must have is_staff=True.')
- if extra_fields.get('is_superuser') is not True:
- raise ValueError('Superuser must have is_superuser=True.')
- return self._create_user(email, password, **extra_fields)
- class CustomUser(AbstractBaseUser, PermissionsMixin):
- email = models.EmailField(
- max_length=250,
- unique=True,
- )
- is_staff = models.BooleanField(
- _('staff status'),
- default=False,
- help_text=_('Designates whether the user can log into this admin site.'),
- )
- is_active = models.BooleanField(
- _('active'),
- default=True,
- help_text=_(
- 'Designates whether this user should be treated as active. '
- 'Unselect this instead of deleting accounts.'
- ),
- )
- date_joined = models.DateTimeField(_('date joined'), default=datetime.now)
- objects = CustomUserManager()
- REQUIRED_FIELDS = []
- USERNAME_FIELD = 'email'
- def get_short_name(self):
- "Returns the short name for the user."
- return self.email
- settings.py
- SOCIAL_AUTH_PIPELINE = (
- 'social_core.pipeline.social_auth.social_details',
- 'social_core.pipeline.social_auth.social_uid',
- 'social_core.pipeline.social_auth.auth_allowed',
- 'social_core.pipeline.social_auth.social_user',
- #'social_core.pipeline.user.get_username', <-- Comment this one out and use below instead to create the acc.
- 'Eapp.facebook.creates' #<---
- 'social_core.pipeline.user.create_user',
- 'social_core.pipeline.social_auth.associate_user',
- 'social_core.pipeline.social_auth.load_extra_data',
- 'social_core.pipeline.user.user_details',
- )
- def creates(*args, **kwargs):
- print('##################################')
- print(args)
- print('##################################')
- print(kwargs)
- print('##################################')
- No module named 'Eapp.facebook.createssocial_core'; 'Eapp.facebook' is not a package
- SOCIAL_AUTH_PIPELINE = (
- 'home.pipeline.[function_name]',
- )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement