Search code examples
pythondjangohttp-redirectdjango-views

NoReverseMatch at /login/login/signup


I am trying to create a sign up page using Django. After the user presses the sign up button, I want the page to redirect them to another page using this line of code:

return redirect('congrat')

and also a function for "congrat" has already been created by me:

def congrat(request):
    return render(request,"login/congratulation.html")

also the url has been defined in the urls.py file:

path("login/congrat",views.congrat,name = "congrat"),

but for some reason this is the output from the website after the button is clicked:

screenshot

I have consulted ChatGPT which told me to check my urls.py and check if the function was defined which I have done and I can't seem to find an error there.

The code in the urls.py:

urlpatterns = [path('',views.home,name = "home"),
           path("sign_up_new/",views.sign_up_new,name = "sign_up_new"),
           path("congrat/",views.congrat,name = "congrat"),
           path("login/log_inn",views.log_inn,name = "log_inn"),
           path("success/",views.success,name = "success"),]

Solution

  • Use as below.

    return redirect('/login/congrat')