Hyperlink redirect is not working in Django
I have the below code as part of my project. But instead of redirecting to the HTML page (contact.html
), it is redirecting back to the home page or index.html
.
main_app/urls.py
:
path("", home_views.index, name='home_page'),
path("contact", home_views.contact, name='contact'),
main_app/home_views.py
:
def index(request):
return render(request, 'Varsity/index.html')
def contact(request):
return render(request, 'Varsity/contact.html')
Varsity/index.html
:
<li><a href="{% url 'contact' %}">Contact</a></li>
Terminal
[05/Sep/2022 14:34:43] "GET /contact HTTP/1.1" 302 0