django遇到ConnectionResetError:[WinError 10054]

时间:2018-02-12 13:07:15

标签: javascript jquery django twitter-bootstrap

我是django的新手,想在网页上写一个简单的日志 前端:html,css,javascript(使用bootstrap和jquery) 填写用户名和密码并单击登录按钮后,应该跳转到主页。 这是我的代码: HTML:

 <form id="sign-form" role="form">
     {% csrf_token %}

     <div class="form-group">
         <label for="name" class="sr-only"> username </label>
         <input id="name" type="text" class="form-control" placeholder="Username...">
     </div>

     <div class="form-group">
         <label for="password" class="sr-only"> password </label>
         <input id="password" type="password" class="form-control" placeholder="Password...">
     </div>

     <div class="form-group">
         <button class="btn btn-block" id="sign-in-button"> Sign in </button>
     </div>

     <div class="form-group">
         <button class="btn btn-block" id="sign-up-button"> Sign up </button>
     </div>

</form>

JS:

$("#sign-in-button").click(function () {
    var name=$("#name").val();
    var word=$("#password").val();

    $.post("/login/",
        {
            'username': name,
            'password': word
        },
        function (result) {
            alert(result);
        }
        );

});

网址:

urlpatterns = [
    path('admin/', admin.site.urls),
    path(r'landing/', views.landing_page),
    path(r'login/', views.login),
    path(r'homepage/', views.home_page),
]

的观点:

def landing_page(request):
    return render(request, "landingPage.html")


def login(request):
    print("here log in")
    if request.method == 'POST':
        username = request.POST.get('username')
        password = request.POST.get('password')
        user = auth.authenticate(username=username, password=password)
        print(username+" out")
        if user is not None:
            auth.login(request, user)
            print(username)
            return render(request, "homePage.html", {'username': username})
        return render(request, "homePage.html")

    return render(request, "homePage.html")

但是我遇到了这个问题(请看一下图片): The remote host forced the closure of an existing connection

The remote host forced the closure of an existing connection

The remote host forced the closure of an existing connection

0 个答案:

没有答案