2

I'm working on django app and i'm facing a problem when i need to navigate from my index.html page to another about.html page. I'm setting everything in this way below:

urls.py (myproject)

from django.urls import path, include
urlpatterns = [
    path('', include('weather_app.urls')),
    path('about/', include('weather_app.urls'))
]

urls.py (myapp)

from django.urls import path
from . import views

urlpatterns = [
    path('', views.index, name='index'),
    path('about/', views.about, name="about")
]

In index.html, everything is working well, so i will not put the code.

and in view.py:

from django.shortcuts import render
import requests

def about(request):
   return render(request, "about.html")

i have the code below in my index.html:

<a href="/about.html/">About </a> 

and i cannot get about.html page when click About link as you can see above.

Can anybody help me?

Thanks in advance..

2
  • You don't have a page with the URL "/about.html/". You have one with the URL "/about/". Commented Oct 12, 2018 at 13:30
  • Remove the 'about' url in your project's urls.py. The way you've written it dosn't work unless you mean /about/about/. Commented Oct 12, 2018 at 13:32

1 Answer 1

5

You have to use this tag to avoid manual rendering of urls. In your code:

<a href="{% url 'about' %}">About </a>

Let me know if this works!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.