本文整理汇总了Python中core.models.UserProfile.phone方法的典型用法代码示例。如果您正苦于以下问题:Python UserProfile.phone方法的具体用法?Python UserProfile.phone怎么用?Python UserProfile.phone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类core.models.UserProfile
的用法示例。
在下文中一共展示了UserProfile.phone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: account
# 需要导入模块: from core.models import UserProfile [as 别名]
# 或者: from core.models.UserProfile import phone [as 别名]
def account(request):
user = request.user
try:
profile = UserProfile.objects.get(user=request.user)
except:
profile = UserProfile()
profile.new(user, ip_address=get_remote_ip(request))
profile.save()
form = AccountForm({"phone": profile.phone, "email": user.email})
error = ""
if request.method == "POST":
form = AccountForm(request.POST)
if form.is_valid():
# user.email = form.cleaned_data['email']
user.save()
profile.phone = form.cleaned_data["phone"]
profile.save()
return index(request, "Your account has successfully been edited.")
else:
error = form.errors
return load_page(request, "account.html", {"form": form, "error": error})