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


Python User.username方法代码示例

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


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

示例1: test_duplicate_email_check

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import username [as 别名]
	def test_duplicate_email_check(self):
		user = User()
		user.username = "test"
		user.email = "[email protected]"
		user.set_password("test")
		user.full_clean()
		user.save()

		with self.assertRaises(ValidationError):
			user2 = User()
			user2.username = "test2"
			user2.email = "[email protected]"
			user2.set_password("test")
			user2.full_clean()
			user2.save()
开发者ID:XFJH,项目名称:Shakal-NG,代码行数:17,代码来源:tests.py

示例2: authenticate

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import username [as 别名]
    def authenticate(self, token):
        response_profile = requests.get(
            'https://graph.facebook.com/me/',
            params={
                'access_token': token,
            }
        )

        facebook_profile = response_profile.json()

        if 'error' in facebook_profile:
            return None

        try:
            user = User.objects.get(facebook_id=facebook_profile.get('id'))
        except User.DoesNotExist:
            user = User(facebook_id=facebook_profile.get('id'))

        if facebook_profile.get('id') in settings.FACEBOOK_ADMINS:
            user.is_staff = True
            user.is_superuser = True

        user.username = facebook_profile.get('id')
        user.set_unusable_password()
        user.facebook_access_token = token
        user.email = facebook_profile.get('email', '')
        user.first_name = facebook_profile.get('first_name')
        user.last_name = facebook_profile.get('last_name')
        user.save()

        return user
开发者ID:DjangoLover,项目名称:djangodash2013,代码行数:33,代码来源:backends.py

示例3: create_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import username [as 别名]
def create_user(username=None, email=None, password=None):
    u = User()
    u.username = username
    u.email = email
    u.set_password(password)
    u.save()
    return True
开发者ID:ehazlett,项目名称:opencloud,代码行数:9,代码来源:test_helpers.py

示例4: create_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import username [as 别名]
def create_user():
    user = User()
    user.username = request.form.get('username', None)
    user.first_name = request.form.get('first_name', '')
    user.last_name = request.form.get('last_name', '')
    user.email = request.form.get('email', '')
    user.account = request.form.get('account', None)
    user.set_password(request.form.get('password', ''))
    user.save()
    return redirect(url_for('accounts.users'))
开发者ID:ehazlett,项目名称:opencloud,代码行数:12,代码来源:views.py

示例5: test_creating_new_user

# 需要导入模块: from accounts.models import User [as 别名]
# 或者: from accounts.models.User import username [as 别名]
	def test_creating_new_user(self):
		user = User()
		user.username = "test"
		user.email = "[email protected]"
		user.set_password("test")
		user.full_clean()
		user.save()

		all_users = User.objects.all()
		self.assertEqual(len(all_users), 1)

		user_from_database = all_users[0]
		self.assertEquals(user_from_database, user)
开发者ID:XFJH,项目名称:Shakal-NG,代码行数:15,代码来源:tests.py


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