当前位置: 首页>>代码示例>>Python>>正文


Python ProfileForm.is_valid方法代码示例

本文整理汇总了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)
开发者ID:miri64,项目名称:share_datalove,代码行数:44,代码来源:views.py


注:本文中的models.ProfileForm.is_valid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。