models.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:cyphon 作者: dunbarcyber 项目源码 文件源码
def _create_user(self, email, password, is_staff,
                     is_superuser, is_active, **extra_fields):
        """
        Creates and saves a User with the given email and password.
        """
        try:
            now = timezone.now()
            if not email:
                raise ValueError('The given email must be set')
            email = self.normalize_email(email)
            user = self.model(email=email, is_staff=is_staff,
                              is_active=is_active, is_superuser=is_superuser,
                              date_joined=now, **extra_fields)
            user.set_password(password)
            user.save(using=self._db)
            return user
        except IntegrityError:
            _LOGGER.error('Cannot create new user with email %s. '
                         'A user with that email already exists.', email)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号