I'm trying to add a link to my django site that redirects from the catalog1
view to the catalog2
page. So basically, I want to go from .../catalog1
to .../catalog2/other-page
.
All the other answers that I've seen require redirecting to http://127.0.0.1:8000/
first, and then redirecting to catalog2
, but I've set up the site so that http://127.0.0.1:8000/
automatically redirects to catalog1
, so this isn't working.
Any help would be appreciated.
Thanks,
FluffyGhost
CodePudding user response:
Assume, a situation , your other-page
is about
,you have about
button in your path http://127.0.0.1:8000/catalog1
catalog1.html
<a href="{% url 'about' %}">about </a>
urls.py
urlpatterns =[
path('catalog2/about/',views.about,name='about')
]
views.py
def about(req):
return render(req,'appname/anyfile.html')
So, by clicking on a button about
, it will redirect it to that view which has name='about'
in urls.py
irrespective of any route.
Then you are redirected to http://127.0.0.1:8000/catelog2/about/
from http://127.0.0.1/8000/catalog1
.