How to link to another page using Django template tags

Django Bindings has been deprecated. For more, see the Deprecation Notice.

To link to another page in an app, reconstruct the URL to it using the {% url 'app_name:page_name' %} template tag with the app's name and the page's name:

  • The Web Framework uses namespaces to eliminate conflicts between different apps. For example, specifying {% url app1:home %} and {% url app2:home %} indicates whether the Home page belongs to app1 or app2.
  • The Web Framework uses the filename (without the .html extension) as the page name unless you explicitly specify a different internal name for the template in the URL mapping. For example, the name of mypage.html is "mypage" unless you set up a custom URL mapping.

For example, to link to mypage.html in the app called "myapp", use the following code in your template:

This is the URL for "mypage": <a href="{% url 'myapp:mypage' %}">Click here</a>