本文整理汇总了Python中accounts.models.UserProfile.birthday方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.birthday方法的具体用法?Python UserProfile.birthday怎么用?Python UserProfile.birthday使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类accounts.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.birthday方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: signup
# 需要导入模块: from accounts.models import UserProfile [as 别名]
# 或者: from accounts.models.UserProfile import birthday [as 别名]
def signup(request):
context = {}
context['title'] = _('Register')
user = User()
if request.user.is_authenticated():
return redirect('accounts_accounts')
userProfile = UserProfile()
if request.method == 'POST':
userForm = UserForm(request.POST, instance=user)
userProfileForm = UserProfileForm(request.POST, instance=userProfile)
if userForm.is_valid() and userProfileForm.is_valid():
userData = userForm.cleaned_data
user.username = userData['username']
user.first_name = userData['first_name']
user.last_name = userData['last_name']
user.email = userData['email']
user.set_password(userData['password'])
user.save()
userProfile = user.get_profile()
userProfileData = userProfileForm.cleaned_data
userProfile.gender = userProfileData['gender']
userProfile.birthday = userProfileData['birthday']
userProfile.save()
user = authenticate(username=userData['username'], password=userData['password'])
login(request, user)
return redirect('accounts_accounts')
else:
userForm = UserForm(instance=user)
userProfileForm = UserProfileForm(instance=userProfile)
context['userForm'] = userForm
context['userProfileForm'] = userProfileForm
return render_to_response('accounts/register.html', context, context_instance=RequestContext(request))