Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class EditUserForm(forms.ModelForm):
- class Meta:
- model = User
- fields = ('first_name', 'last_name', 'email',)
- class EditProfileForm(forms.ModelForm):
- def __init__(self, *args, **kwargs):
- super(EditProfileForm, self).__init__(*args, **kwargs)
- profile = kwargs.get('instance')
- if profile:
- kwargs['instance'] = profile.user
- self.user_form = EditUserForm(*args, **kwargs)
- self.fields.update(self.user_form.fields)
- self.initial.update(self.user_form.initial)
- def save(self, *args, **kwargs):
- self.user_form.save(*args, **kwargs)
- return super(EditProfileForm, self).save(*args, **kwargs)
- class Meta:
- model = UserProfile
- exclude = ('user',)
Add Comment
Please, Sign In to add comment