def edit_profile_v(request): form = EditProfileForm(initial = {'first_name' : request.user.first_name, 'last_name' : request.user.last_name, 'email' : request.user.email}) if request.method == 'POST': form = EditProfileForm(request.POST) if form.is_valid(): form.save(request.user) return HttpResponseRedirect('/successful/') return render_to_response('UserManagement/edit_profile.xhtml', { "form": form, "title" : "Edit profile" }, context_instance = RequestContext(request));
def edit_profile(request): error = '' if request.method == 'POST': form = EditProfileForm(request.POST) if form.is_valid(): # All validation rules pass first_name = form.cleaned_data['first_name'] last_name = form.cleaned_data['last_name'] email = form.cleaned_data['email'] user = User.objects.get(username=request.user) user.first_name = first_name user.last_name = last_name user.email = email user.save() return HttpResponseRedirect('/accounts/') return HttpResponseRedirect('/accounts/edit_profile/') user = request.user initial = { 'first_name': user.first_name, 'last_name': user.last_name, 'email': user.email, } form = EditProfileForm(initial) return render_to_response('user_management/edit_profile.html', { 'error': error, 'form': form, }, context_instance=RequestContext(request))