It worked for me....!! Please review my code... and let me know if I have done everything correct...!!
On Sun, Aug 2, 2015 at 12:25 PM, sarfaraz ahmed <[email protected]> wrote: > Changed the edit_user to following. it works fine except... newly added > field date_of_birth does not load data. > Please take a look at link below > http://pastebin.com/nXpiLMJp > > ------------------------------------------------------------------------------------------------------------ > Regards, > Sarfaraz Ahmed > > > On Sunday, 2 August 2015 01:28:37 UTC+5:30, sarfaraz ahmed wrote: >> >> Hello Team, >> >> I have extending the user with userprofile. I want to change first_name, >> last_name and sex from userprofile using one template. I have defined form >> and models. Please hellp this is code for edit_user view, model for user >> profile and model forms code >> >> >> ----------------------------------------------------------------------------------------------- >> >> class UserProfile(models.Model): >> >> user = models.OneToOneField(User) >> activation_key = models.CharField(max_length=40,blank=True) >> sex = models.CharField(max_length=6, choices=( >> ('male', 'Male'), >> ('female', 'Female'),)) >> key_expires = models.DateTimeField(default=datetime.date.today()) >> >> def __str__(self): >> return self.user.username >> >> class Meta: >> verbose_name_plural=u'User profiles' >> >> ----------------------------------------------------------------------------------------------- >> class UserProfileForm(forms.ModelForm): >> class Meta: >> model=User >> fields =('first_name','last_name') >> >> class UserProfileForm1(forms.ModelForm): >> class Meta: >> model=UserProfile >> fields=('sex',) >> >> >> ---------------------------------------------------------------------------------------------- >> def edit_user(request): >> args={} >> if request.method=="POST": >> form=UserProfileForm(request.POST, instance=request.user) >> >> if form.is_valid(): >> form.save() >> form1=UserProfileForm1(request.POST, instance=request.user) >> if form1.is_valid(): >> form1.save() >> UserProfile.save() >> return HttpResponseRedirect('/useraccount/edit_user') >> else: >> form=UserProfileForm() >> form1=UserProfileForm1() >> >> args['form']=form >> args['form1']=form1 >> >> return render(request,'useraccount/edit_user.html',args) >> >> Now the i go to edit user view it load blank and do nothing when I click >> on save. Please help >> >> Regards, >> Sarfaraz Ahmed >> >> -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/ded7528b-5ca4-46bb-b222-7039892c23b5%40googlegroups.com > <https://groups.google.com/d/msgid/django-users/ded7528b-5ca4-46bb-b222-7039892c23b5%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- Thanks with regards, Sarfaraz Ahmed -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAEPJdiwOFX1aZfuhEiEs4yBrKurkG2k4%2BkT7OTg3Z0b4wzEQGA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

