本文整理汇总了Python中accounts.models.UserProfile.nickname方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.nickname方法的具体用法?Python UserProfile.nickname怎么用?Python UserProfile.nickname使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.nickname方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: welcome_douban
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import nickname [as 别名]
def welcome_douban(request):
api_operation = ApiOperation(key='default')
results = None
error_message = ''
key = request.GET.get('oauth_token', '')
if key:
request_token = getRequestToken(key)
if request_token:
results = api_operation.getServiceFromRequest(request_token)
if results:
service, uid = results
profile = UserData(uid).getProfile()
if profile:
try:
new_user = User.objects.create_user(username = profile['uid'],
password = profile['uid'])
new_user.backend="%s.%s" %('django.contrib.auth.backends','ModelBackend')
#以新用户登陆
auth.login(request, new_user)
info = UserProfile(user=new_user)
info.nickname = profile['nickname']
info.image_link = profile['image_link']
info.sign = profile['signature']
info.website = profile['website']
info.introduction = profile['introduction']
info.did = profile['uid']
try:
info.save()
except Exception, error:
logger.debug(str(error))
#启动新用户的后台线程 完成推荐数据的初始化
InitData.initUserData(uid)
#设置密码, 默认为用户名
user_form = UserChangeForm(instance=new_user)
return render_to_response("accounts/settings.html", {
'msg':"请设置登录密码, 现在默认和用户名相同",
'user_form':user_form
},context_instance=RequestContext(request))
except Exception, error:
error_message = _("Sorry, we have a error when create new user: %s."%(error))