本文整理汇总了Python中models.Profile.phone方法的典型用法代码示例。如果您正苦于以下问题:Python Profile.phone方法的具体用法?Python Profile.phone怎么用?Python Profile.phone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Profile
的用法示例。
在下文中一共展示了Profile.phone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: profile
# 需要导入模块: from models import Profile [as 别名]
# 或者: from models.Profile import phone [as 别名]
def profile(request):
try:
profile = request.user.get_profile()
except Profile.DoesNotExist:
profile = Profile(user=request.user)
if request.method == 'POST':
form = ProfileForm(request.POST)
if form.is_valid():
request.user.first_name = form.cleaned_data['first_name']
request.user.last_name = form.cleaned_data['last_name']
request.user.email = form.cleaned_data['email']
if len(form.cleaned_data['password1']) > 0:
request.user.set_password(form.cleaned_data['password1'])
request.user.save()
profile.phone = form.cleaned_data['phone']
profile.save()
messages.info(request, 'Vaše informácie boli upravené')
return HttpResponseRedirect('/')
else:
form = ProfileForm(initial={'first_name': request.user.first_name,
'last_name': request.user.last_name,
'email': request.user.email,
'phone': profile.phone,
})
page_info = {}
page_info['title'] = 'Informácie o Vás - Váš profil'
page_info['page'] = 0
page_info['form_name'] = 'settings'
page_info['form_action'] = '/nastavenia/'
return render_to_response('registracia.html', {'form': form, 'countInfo': countInfo, 'recentNews': recentNews,
'page_info': page_info},
context_instance=RequestContext(request))