Skip to content
Advertisement

Best way of linking to a page in Django

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

The next thing I put this tag into the href:

JavaScript

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

Then in your html you can use either one:

JavaScript

You can of course use the template tage {% url 'index' %} as many times as you need in any template.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement