title: Create dynamic arguments for url_for in Flask
body: <p>I have a jinja2 template which I reuse for different Flask routes. All of these routes have a single required parameter and handle only <code>GET</code> requests, but some routes may have extra arguments.</p>
  
  <p>Is there a way to append extra arguments onto <code>url_for()</code>?</p>
  
  <hr>
  
  <p>Something like</p>
  
  <pre><code>url_for(my_custom_url, oid=oid, args=extra_args)
  </code></pre>
  
  <p>which will render to (depending on the route endpoint):</p>
  
  <pre><code># route 'doit/&lt;oid&gt;' with arguments
  doit/123?name=bob&amp;age=45
  
  # route 'other/&lt;oid&gt;' without arguments
  other/123
  </code></pre>
  
  <p>My use case would be to provide links with predefined query arguments:</p>
  
  <pre><code>&lt;a href=" {{ url_for('doit', oid=oid, args=extra_args }} "&gt;A specific query&lt;/a&gt;
  &lt;a href=" {{ url_for('other', oid=oid) }} "&gt;A generic query&lt;/a&gt;
  </code></pre>
  
  <p>I would like to run this template without JavaScript, so I would not like to assign a click listener and use AJAX to do a <code>GET</code> request for each link if that is possible.</p>