def form_valid(self, form): a = Address() a.streetNumber = form.cleaned_data.get('streetNumber') a.street = form.cleaned_data.get('street') a.city = form.cleaned_data.get('city') a.province = form.cleaned_data.get('province') a.postalCode = form.cleaned_data.get('postalCode') a.save() self.object = form.save(commit=False) self.object.addressID = a self.object.UserID = self.request.user self.object.dateofBirth = form.cleaned_data.get('dateofBirth') self.object.save() # accountInfo = AccountInfo.objects.get(AccountInfoID=self.request.session.accountInfo.accountInfoID) accountInfo = AccountInfo.objects.get(AccountInfoID=str( self.request.session['accountInfo'].get("AccountInfoID"))) accountInfo.personalInfoID = self.object.PersonInfoID accountInfo.save() self.request.session['accountInfo'] = model_to_dict(accountInfo) if (accountInfo.isBoxer == True): return HttpResponseRedirect(reverse('fightscheduler:careerCreate')) elif (accountInfo.isCoach == True or accountInfo.isOwner == True or accountInfo.isOfficial == True or accountInfo.isBoxingOntarioAdmin == True): return HttpResponseRedirect( reverse('fightscheduler:otherInfoCreate')) else: return HttpResponseRedirect(reverse('fightscheduler:main'))
def form_valid(self, form): self.object = form.save(commit=False) a = Address() a.AddressID = form.cleaned_data.get('addressID') a.streetNumber = form.cleaned_data.get('streetNumber') a.street = form.cleaned_data.get('street') a.city = form.cleaned_data.get('city') a.province = form.cleaned_data.get('province') a.postalCode = form.cleaned_data.get('postalCode') a.save() print (str(form.cleaned_data.get('dateofBirth')) + "\n") self.object.dateofBirth = form.cleaned_data.get('dateofBirth') print (self.object.dateofBirth) # self.object.dateofBirth = datetime.strptime(form.cleaned_data('dateOfBirth'),"%m/%d/%Y") self.object.save() return HttpResponseRedirect(reverse('fightscheduler:personalInfoUpdate'))
def form_valid(self, form): a = Address() a.streetNumber = form.cleaned_data.get('streetNumber') a.street = form.cleaned_data.get('street') a.city = form.cleaned_data.get('city') a.province = form.cleaned_data.get('province') a.postalCode = form.cleaned_data.get('postalCode') a.save() self.object = form.save(commit=False) self.object.addressID = a self.object.UserID = self.request.user self.object.dateofBirth = form.cleaned_data.get('dateofBirth') self.object.save() # accountInfo = AccountInfo.objects.get(AccountInfoID=self.request.session.accountInfo.accountInfoID) accountInfo = AccountInfo.objects.get(AccountInfoID=str(self.request.session['accountInfo'].get("AccountInfoID"))) accountInfo.personalInfoID = self.object.PersonInfoID accountInfo.save() self.request.session['accountInfo'] = model_to_dict(accountInfo) return HttpResponseRedirect(reverse('fightscheduler:careerCreate'))