Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 当前路径accounts/signUp/signUp没有';我一个也配不上_Python_Html_Django_Postgresql - Fatal编程技术网

Python 当前路径accounts/signUp/signUp没有';我一个也配不上

Python 当前路径accounts/signUp/signUp没有';我一个也配不上,python,html,django,postgresql,Python,Html,Django,Postgresql,你好,我在django中尝试创建注册页面时遇到了一个问题 当我以html表单提交时,应该在数据库中创建一个用户,但它没有发生,并且显示了此消息 当前路径accounts/signUp/signUp与这些路径中的任何一个都不匹配 这个在候机楼 “未找到:/accounts/signUp/signUp” 视图。py: from django.shortcuts import render,redirect from django.contrib.auth.models import User,aut

你好,我在django中尝试创建注册页面时遇到了一个问题

当我以html表单提交时,应该在数据库中创建一个用户,但它没有发生,并且显示了此消息

当前路径accounts/signUp/signUp与这些路径中的任何一个都不匹配 这个在候机楼 “未找到:/accounts/signUp/signUp”

视图。py:

from django.shortcuts import render,redirect
from django.contrib.auth.models import User,auth
# Create your views here.


def signUp(request):

    if request.method=='post':
        first_name=request.POST['first_name']
        last_name=request.POST['last_name']
        username=request.POST['username']
        password1=request.POST['password1']
        rePassword=request.POST['repassword']
        email=request.POST['email']

        user = User.objects.create_user(username=username,password=password1,email=email,first_name=first_name,last_name=last_name)
        user.save();
    
    else:    
        return render(request,'signUp.html')
signUp.html

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Sign Up</title>
</head>
<body>
    <form action="signUp" method="post">
        {% csrf_token%}

        <input type="text" name="first_name" placeholder="First Name"><br>
        <input type="text" name="last_name" placeholder="Last Name"><br>
        <input type="text" name="username" placeholder="Username"><br>
        <input type="email" name="email" placeholder="email"><br>
        <input type="password" name="password" placeholder="Password"><br>
        <input type="password" name="rePassword" placeholder="Confirm Password"><br>
        <input type="submit">
    </form>
</body>
</html>

注册
{%csrf_令牌%}






form action=“signUp”

提交表单时,这不会起任何作用

您需要将其更改为您的
注册
url

因此,如果您的url是
path('signup/',views.signup,name='signup')

您将使用:
表单操作=“{%url”注册“%”

另一件事是,在处理
POST
时,您的视图似乎没有显示任何注册成功消息,您可能希望将它们重定向到另一个页面或包含一条成功消息。

错误来自您的URL(或路由器,如果您使用过它们)。请继续关注