class UpdateProfile(UpdateView):
model = User
fields = ['first_name', 'last_name', 'username', 'email']
template_name = 'account/update.html'
success_url = '/accounts/profile/'
def get_object(self, queryset=None):
return self.request.user
def clean_email(self):
email = self.cleaned_data.get('email')
username = self.cleaned_data.get('username')
if email and User.objects.filter(email=email).exclude(username=username).count() > 0:
raise forms.ValidationError(u'This email address is already registered.')
return email
class UpdateProfile(UpdateView):
model = Us