Is there feature in Pyramid to specify a route in the template like Django templates?

pyramid, python

Solution

The brackets depend on the templating engine you are using, but `request.route_url('home')` is the Python code you need inside.

For example, in your desired template file:

- jinja2--> `{{ request.route_url('home') }}`

- mako/chameleon--> `${ request.route_url('home') }`

If your route definition includes pattern matching, such as `config.add_route('sometestpage', '/test/{pagename}')`, then you would do `request.route_url('sometestpage', pagename='myfavoritepage')`

Problem

For example in Django if I have a url named 'home' then I can put {% url home %} in the template and it will navigate to that url. I couldn't find anything specific in the Pyramid docs so I am looking to tou Stack Overflow. Thanks

Original source