提交登录按钮时,我的网页没有任何反应

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了提交登录按钮时,我的网页没有任何反应相关的知识,希望对你有一定的参考价值。

我的html

<form method="POST" action="{% url 'lawyerdash' %}">
    {% csrf_token %}
    username<input type="text" name="username"><br>
    password<input type="password" name="password" ><br>

    <input type="button" value="sign in" >

我的观点是

  def lawyerdash(request):
        if request.method == 'POST':
            if Lawyer.objects.filter(username=request.POST['username'], password=request.POST['password']).exists():
                lawyer = Lawyer.objects.get(username=request.POST['username'], password=request.POST['password'])

                return render(request, 'lawyerpage.html', {'lawyer': lawyer})
      else:
          return HttpResponse("<h1>Not found.........</h2>")

我的网址是

url(r'^lawyerdash/$',views.lawyerdash,name="lawyerdash"),

单击登录后,应转到以下页面(lawyerpage.html)

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h1>welcome {{lawyer.name}}</h1>
</body>
</html>
答案

您应该使用<input type="submit">Sign In</input>而不是类型按钮

另一答案
<input type='submit'>Sign In</input>

是您真正需要的。 “按钮”类型适用于链接等,因为它只是可单击的按钮。 “重置”类型会将页面上的表单重置为其初始值。 “提交”类型将提交您的表单数据。

以上是关于提交登录按钮时,我的网页没有任何反应的主要内容,如果未能解决你的问题,请参考以下文章

按下谷歌登录按钮时没有任何反应

按钮在片段中不起作用

出现连接玩游戏但没有任何反应

使用 ajax 提交结帐表单

添加到片段时按钮不起作用

没有使用 navController.currentDestination?.id 获取当前片段 ID