def update_user(request): args = {} template_name = 'kitchen/crispy.html' if request.method == 'POST': form = UserUpdate(request.POST, instance=request.user) if form.is_valid(): form.save() return redirect('account-list') else: form = UserUpdate(instance=request.user) args['form'] = form return render_to_response(template_name, {'form': form}, context_instance=RequestContext(request))
def edit_profile(request): context = RequestContext(request) user = request.user up = UserProfile.objects.get(user = user.id) redirect = get_redirect_url(request) if request.method == 'POST': form = UserUpdate(request.POST,instance = up) if form.is_valid(): form.save() return HttpResponseRedirect(redirect) else: form = UserUpdate(instance = up) context_dict = {'user' : user, 'form' : form, 'UP' : up} return render_to_response('user_profile/edit_profile.html', context_dict, context)