Search code examples
pythontornado

Reverse URL in template


In a template, how can I map a name back into a URL, similar to Django's {% url %} tag?

I read that reverse_url was supposed to work, but this gave an error:

<li> <a href="{% reverse_url('login') %}">Login</a> </li>

Solution

  • You want {{ reverse_url('login') }}. That is, a template expression rather than directive. The syntax reference is here (it's brief).