+ 1
Django redirect() problem help !!!
My Django project has only one app wiki, projects index goes to appâs index page which is 127.0.0.1:8000 I am at the url: 127.0.0.1:8000/wiki/newpage This urlâs view: . . return redirect(fâwiki/{title}â) My all URLs list is as follows for the wiki app: 1. ââ 2. wiki/newpage 3. wiki/random 4. wiki/<str:search> <â url I want to redirect 5. wiki/ <â url is for query search But the view returns: wiki/wiki/{title} I tried removing the wiki from redirect() and it becomes fâ/{title}â but now this goes to 127.0.01:8000/{title} I finally want the answer to redirect to 127.0.0.1:8000/wiki/{title} Thank you in advance.
1 RĂ©ponse
+ 2
You should write return redirect(f"/wiki/{title}") to achieve this (with slash at the beginning).
Also you can think about using reverse() function instead of hardcoding path for redirect.