Search code examples
pythonflaskjinja2

How to use jinja variable inside a variable


<a href="{{ url_for('osupgrade.download_stage_log',url = result.download_url) }}"  type="submit" target="_self">Download</a>

result.download_url --> This also a variable How can use that? I tried with curly etc, all is failing.


Solution

  • Here's how you should structure your url:

    <a href="{{ url_for('osupgrade.download_stage_log', url='') }}{{result.download_url}}"  type="submit" target="_self">Download</a>
    

    The value passed to the variable url is in a pair of braces isolated from the rest