typ<form action="register" 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="username" 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="confirm_password" placeholder="confirm_password"><br>
<input type="submit" name="submit" value="Register">
</form>e here
def register(request):
# print("in register")
# if request.method=="GET":
# return render (request,"register.html")
if request.method=="POST":
print("IN POST")
first_name=request.POST.get('first_name')
last_name=request.POST['last_name']
username=request.POST['username']
email=request.POST['email']
password=request.POST['password']
confirm_password=request.POST['confirm_password']
user=User.objects.create_user(username=username,password=password,email=email,first_name=first_name,last_name=last_name)
user.save()
print("User Created")
return redirect(home)
# if password==confirm_password:
# if User.objects.filter(username=username).exists():
# print("Username Already Taken")
# elif (User.objects.filter(email=email)):
# print("Email Already Taken")
# else:
# user=User.objects.create_user(username=username,password=password,email=email,first_name=First_name,last_name=Lirst_name)
# user.save()
# print("User Created")
# return redirect('/')
# else:
# print("Password and Confirm Password Does Not Match")
else:
return render (request,"register.html")
Expecting redirect to home page but its showing error:
Page not found (404)
Request Method: POST
Request URL: http://127.0.0.1:8000/register/register
Using the URLconf defined in Finance_Tracker.urls, Django tried these URL patterns, in this order:
[name=’home’]
register/ [name=’register’]
admin/
The current path, register/register, didn’t match any of these.
Debasish Kundu is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.