当前位置: 首页>>代码示例>>Python>>正文


Python UserProfile.activation_key方法代码示例

本文整理汇总了Python中accounts.models.UserProfile.activation_key方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.activation_key方法的具体用法?Python UserProfile.activation_key怎么用?Python UserProfile.activation_key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在accounts.models.UserProfile的用法示例。


在下文中一共展示了UserProfile.activation_key方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create

# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import activation_key [as 别名]
    def create(self, validated_data):
        datas = {}
        datas['username'] = validated_data['username']
        datas['email'] = validated_data['email']
        datas['password'] = validated_data['password']
        datas['first_name'] = validated_data['first_name']
        datas['last_name'] = validated_data['last_name']
        datas['password'] = validated_data['password']

        data = utils.generate_activation_key(datas['username'])     # user defined utility function.
        datas['activation_key'] = data
        datas['file_path'] = "accounts/activate/"
        datas['email_path'] = "/ActivationEmail.txt"
        datas['email_subject'] = "Activate Your domainname account."

        new_user = User.objects.create_user(
                username=datas['username'],
                email=datas['email'],
                password=datas['password'],
                first_name=datas['first_name'],
                last_name=datas['last_name'],
        )
        new_user.is_active = True
        new_user.save()
        user_profile = UserProfile()
        user_profile.user = new_user
        user_profile.activation_key = datas['activation_key']
        user_profile.is_active = False  # Will be true if email is verified.
        user_profile.save()
        utils.send_email(datas)
        # message = '''
        #             A Verification email has been sent to your email address.
        #             Please click the link in the email to verify your email address.
        #             '''
        # utils.display_html_message(message, 'success', request)
        return validated_data
开发者ID:adityamohta,项目名称:custom-registration,代码行数:38,代码来源:serializers.py


注:本文中的accounts.models.UserProfile.activation_key方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。