`<h2>Login</h2>
<form method="post" action="">
{% csrf_token %}
{{ form.as_p }}
</form>
<a href="{% url 'loggedin' %}"><input type="submit" value="login" /></a>`
`<h2>login success</h2>`
`def signin(request):
if request.method == "POST":
form = LoginForm(request.POST) #form = email, password
email_input = str(request.POST['email'])
password_input = str(request.POST['password'])
user_Qset = Profile.objects.filter(email = email_input)
if user_Qset is not None:
password_saved = str(user_Qset.values('password')[0]['password'])
if password_input == password_saved:
response = render(request, 'registration/login.html',)
request.session.modified = True
request.session['name'] = user_Qset.values('name')[0]['name']
request.session['email'] = user_Qset.values('email')[0]['email']
request.session['password'] = user_Qset.values('password')[0]['password']
return response
def loggedin(request):
if request.session.has_key('name'):
return HttpResponse("transmission success")
else:
return HttpResponse("transmission failed")`
我的结果是“传输失败”。如何传输添加的会话? 当我按下登录按钮时,应该更改页面网址和模板并传输会话
用户登录时,我想提供用户会话密钥(名称,电子邮件,密码) 我想查看我提供的会话密钥,该密钥在另一页中保持良好