I am getting page not found 404 ERROR, in Django. Even though i have mapped the URL correctly both in the main app and this app.
urlpatterns = [
path('',views.mainpage,name='main'),
path("signup/",views.signup,name='signup'),
path("login/",views.login,name='login'),
path("logout/",views.logout,name='logout')
]
Now the below url is of the main app where I have included the urls.py of sub-app which is accounts.
urlpatterns = [
path('',include('trial.urls')),
path('accounts/',include('accounts.urls')),
path('admin/', admin.site.urls),
]
This is the URL mapping of the app name accounts, used to handle the account and registration details.
The error is in this path
http://127.0.0.1:8000/accounts/signup/signup
Where as it works finely up to the below mentioned path.
http://127.0.0.1:8000/accounts/signup
Can anyone suggest me or help me finding out where it going wrong. What it should happen is,
http://127.0.0.1:8000/accounts/signup
after this path when we click submit it should create a user in database and return or redirect the page to login page, with a message user created.
Below is the code of views.py of the accounts app.
def signup(request):
if request.method == 'POST':
first_name = request.POST['first_name']
last_name = request.POST['last_name']
username = request.POST['username']
email = request.POST['email']
password1 = request.POST['password1']
user = User.objects.create_user(
firstname=first_name, lastname=last_name, username=username, email=email, password=password1)
user.save()
print("USER CREATED SUCCESSFULLY")
return redirect('/login.html')
Anyone help me out what is going wrong. Thank you.