def profile(request): if request.session.has_key('is_logged'): reg=models.Register.objects.get(id=request.session['id']) fields={'username':reg.username,'mobile':reg.mobile,'email':reg.email} form=NewUserForm(initial=fields) res=render(request,'shop/user_profile.html',{'form':form,'reg':reg}) print("profile id is: ",request.session['id']) return res else: return HttpResponseRedirect("../loginPage")
def updatePro(request): if request.method == "POST": form = NewUserForm(request.POST) res = models.Register() res.id = request.POST['cid'] res.password = request.POST['password'] res.username = form.data['username'] res.email = form.data['email'] res.mobile = form.data['mobile'] res.save() uname = res.username.split() request.session['username'] = uname[0].capitalize() print("username is: ", request.session['username']) return HttpResponseRedirect("../profile/")
def regPage(request): if request.session.has_key('is_logged'): return HttpResponseRedirect("../") form = NewUserForm() res = render(request, 'shop/signup.html', {'form': form}) return res