Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

301
Views
Django: how to make a link on main page to sub-pages

I have had successfully deployed some pages which are in urls.py and could be reached with no problems.
There is also default page should have links to 127.0.0.1/page1 and 127.0.0.1/page2.
How could that be achieved? sitename is in settings.py
I have tried the following in index.html:

<h3>This is the URL for "page1": <a href="{% url 'sitename:page1.html' %}"> Click here</a></h3>
> django.urls.exceptions.NoReverseMatch: 'sitename' is not a registered namespace

<h3>This is the URL for "page1": <a href="{% url 'page1.html' %}"> Click here</a></h3>
> Reverse for 'exp.html' with arguments '()' and keyword arguments '{}' not found. 0 pattern(s) tried: []
over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

I advice you first read this link for understanding django url structure https://docs.djangoproject.com/en/1.10/topics/http/urls/#url-namespaces

The Solution will be like that:

<h3>This is the URL for "page1": <a href="/page1"> Click here</a></h3>

<h3>This is the URL for "page2": <a href="/page2"> Click here</a></h3>

and you must define this urls in urls.py

over 4 years ago · Santiago Trujillo Report

0

It looks like you're trying to pass template name to url template tag. What you should actually do is to define url name in your urls.py, so it would look similiar to this:

url(r'^page1/$', YourView.as_view(), name="page1")

and then in template:

<a href="{% url "page1" %}">Page 1</a>

You should rather avoid hardcoding urls doing something like this:

<a href="/page1">Page 1</a>

because when in future you'd like to change the url you'll have to do it in two places: in urls.py and in template(s), while when using {% url %} template urls.py will be the only place to do it.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!