def edit(request, id): userprofile = Userprofile.objects.get(id = request.user.id) #u = user.user if request.method == 'POST': form = UserprofileForm(request.POST, request.FILES, instance=userprofile) if form.is_valid(): edit_user = form.save(commit=False) edit_user.user = request.user edit_user.save() return HttpResponseRedirect('/accounts/profile/') else: form = UserprofileForm(instance=userprofile) return render_to_response('userprofile/edit_user.html', { 'form': form, }, context_instance=RequestContext(request))
def edit(request): userprofile = Userprofile.objects.get(user = request.user) if request.method == 'POST': form = UserprofileForm(request.POST, request.FILES, instance = userprofile) if form.is_valid(): form.save() user_adds = userprofile.share_set.all() return render_to_response('userprofile/index.html', {'user' : userprofile, 'user_adds': user_adds, }, context_instance=RequestContext(request)) else: form = UserprofileForm(instance=userprofile) return render_to_response('userprofile/edit_user.html', { 'form': form, }, context_instance=RequestContext(request))
def edit(request, id): userprofile = Userprofile.objects.get(id=request.user.id) #u = user.user if request.method == 'POST': form = UserprofileForm(request.POST, request.FILES, instance=userprofile) if form.is_valid(): edit_user = form.save(commit=False) edit_user.user = request.user edit_user.save() return HttpResponseRedirect('/accounts/profile/') else: form = UserprofileForm(instance=userprofile) return render_to_response('userprofile/edit_user.html', { 'form': form, }, context_instance=RequestContext(request))