def Login(request): System_emil = Account_Information.objects.all() if request.method == 'GET': emily = request.GET.get('email') pw = request.GET.get('pswd') # 判断数据库中是否记录了该账号,如果有就登录,没有就注册 print("emily:",emily); print("pw",pw); if(emily == None): print("空") else: if(emily!=""): #定义一个变量data来判断是否已经拥有账号,0就是没有,大于0就是有 data = 0 for AI in System_emil: #在数据库找得到账号就登陆 if(str(emily) == str(AI.web_emaily)): data += 1 if(data==0): Account_Information.objects.create(web_emaily=emily,web_paswd=pw) else: zh = Account_Information.objects.get(web_emaily=emily) if(emily==zh.web_emaily and pw==zh.web_paswd): print("登录") # ret = redirect("/index/") # ret.set_cookie("is_login", emily, expires=60 * 60 * 24 * 7) # return ret return render(request,"login.html");
django实现登录
最新推荐文章于 2024-01-22 23:30:11 发布