本文整理汇总了Python中models.ProfileForm.is_valid方法的典型用法代码示例。如果您正苦于以下问题:Python ProfileForm.is_valid方法的具体用法?Python ProfileForm.is_valid怎么用?Python ProfileForm.is_valid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.ProfileForm
的用法示例。
在下文中一共展示了ProfileForm.is_valid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: editProfile
# 需要导入模块: from models import ProfileForm [as 别名]
# 或者: from models.ProfileForm import is_valid [as 别名]
def editProfile(request):
title="Edit Profile"
if request.method == 'POST':
userform = ProfileForm(request.POST) # A form bound to the POST data
adressform = AdressForm(request.POST)
if userform.is_valid(): # All validation rules pass
oldpassword = userform.cleaned_data['oldpassword']
password = userform.cleaned_data['password']
secpassword = userform.cleaned_data['secpassword']
email = userform.cleaned_data['email']
if adressform.is_valid():
publicadress = adressform.cleaned_data['publicAdress']
country = adressform.cleaned_data['country']
city = adressform.cleaned_data['city']
zipcode = adressform.cleaned_data['zipcode']
street = adressform.cleaned_data['street']
housenumber = adressform.cleaned_data['housenumber']
userprofile = request.user.profile
l = Location(country=country, city=city, zipcode=zipcode, street=street, housenumber=housenumber)
l.save()
userprofile.adress = l
userprofile.publicAdress = publicadress
userprofile.save()
else:
user = request.user
try:
userform = ProfileForm({'email': user.email,})
except:
userform = UserForm()
try:
adressform = AdressForm({
'publicAdress': user.profile.publicAdress,
'country': user.profile.adress.country,
'city': user.profile.adress.city,
'zipcode': user.profile.adress.zipcode,
'street': user.profile.adress.street,
'housenumber': user.profile.adress.housenumber})
except:
adressform = AdressForm()
context = util.generateContext(request, contextType = 'RequestContext', userform=userform, adressform=adressform, title=title)
return render_to_response('usermanag/edit.html', context)