Q: How to use Django reverse urls in Django Templates?

Django Python Reverse urls

Answer:

Instead of hardcoding all links, you can use built-in Django reverse urls. If you were to change a url path, you will not have to update all urls manually if you use reverse urls. In Django template you can use the {% url %} tag.

{% url 'url_name' %}

url_name needs to be replaced with the name of the url.

If you have to pass arguments for the url, you can also include them.

{% url 'url_name' 'arg1' 'arg2' %}
    No comments found for this tutorial, be the first to leave a comment!

Answered by
Double

Last updated on
Aug 12, 2016

Share