+ 1

Django redirect() problem help !!!

My Django project has only one app wiki, projects index goes to app’s index page which is I am at the url: 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{title} Thank you in advance.

12th Sep 2020, 8:24 AM
Adarsh Mamgain
Adarsh Mamgain - avatar
1 Answer
+ 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.
12th Sep 2020, 9:09 AM