I managed to create a URL tag for my index. But right now I’m confused how to add links to other pages.
I put this on my urls.py
JavaScript
x
2
1
url(r'^$', 'index', name='index'),
2
The next thing I put this tag into the href:
JavaScript
1
2
1
{% url 'index' %}
2
But what if I wanted to create a new page and would be linking to it. How would I do it the best way?
Advertisement
Answer
So next you would extend your urls.py
to look something like this:
JavaScript
1
3
1
url(r'^$', 'index', name='index'),
2
url(r'^blog$', 'blog', name='blog'),
3
Then in your html you can use either one:
JavaScript
1
3
1
<a href="{% url 'index' %}">Home</a>
2
<a href="{% url 'blog' %}">Blog</a>
3
You can of course use the template tage {% url 'index' %}
as many times as you need in any template.