本文整理汇总了Python中forum.models.User.username方法的典型用法代码示例。如果您正苦于以下问题:Python User.username方法的具体用法?Python User.username怎么用?Python User.username使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类forum.models.User
的用法示例。
在下文中一共展示了User.username方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_forum_user
# 需要导入模块: from forum.models import User [as 别名]
# 或者: from forum.models.User import username [as 别名]
def update_forum_user(request):
""" Create or Update Forum User model """
try:
# Customise User Model
# username = request.user.username.split('@')[0]
user = User.objects.get(user_ptr_id=request.user.id)
user.user_ptr = request.user
user.save()
except ObjectDoesNotExist:
obj = User()
obj.user_ptr = request.user
obj.email_isvalid = True
obj.last_seen = request.user.last_login
obj.username = request.user.username if '@' not in request.user.username else request.user.username.split('@')[0]
obj.real_name = "%s %s" % (request.user.first_name, request.user.last_name)
# obj.is_active = request.user.is_active
obj.email = request.user.email
obj.profile_image_url = request.session['profile_image'] if 'profile_image' in request.session else ''
obj.save()