title: Can I make Django's {% url %} template tag ignore None when passed as a parameter, so making the parameter optional?
body: <p>I have a site with listings, that I am writing filters for to segment the listings.
  So I could have:</p>
  
  <pre><code>/listings/furniture/
  /listings/london/
  /listings/free/
  </code></pre>
  
  <p>I can also chain these together, eg:</p>
  
  <pre><code>/listings/free/furniture/
  /listings/free/furniture/london/
  </code></pre>
  
  <p>When building links for these filters, I want to leave out the filter if it's set to a default (eg. <code>everywhere</code> or <code>everything</code>.  So rather than saying eg:</p>
  
  <pre><code>/listings/free/everything/everywhere/
  </code></pre>
  
  <p>I would want to just say:</p>
  
  <pre><code>/listings/free/
  </code></pre>
  
  <p>I have an <code>urls.py</code> configuration as follows:</p>
  
  <pre><code>url(r'^listings/(?P&lt;param1&gt;[\w-]+)/$', 'main.web.listings'),
  url(r'^listings/(?P&lt;param1&gt;[\w-]+)/(?P&lt;param2&gt;[\w-]+)/$', 'main.web.listings'),
  url(r'^listings/(?P&lt;param1&gt;[\w-]+)/(?P&lt;param2&gt;[\w-]+)/(?P&lt;param3&gt;[\w-]+)/$', 'main.web.listings'),
  </code></pre>
  
  <p>And when I'm building the url for the links in a template I use code like:</p>
  
  <pre><code>{% url 'main.web.listings' "free" category_selected.slug location_selected.slug %}
  </code></pre>
  
  <p>This would link using the currently selected category and location, and change the page to show only "free" items.</p>
  
  <p>So, to the question:  In the template, I can sometimes have a category_selected.slug and sometimes not, and I would like the <code>{% url ... %}</code> tag to ignore a parameter when it is set to <code>None</code>.  By default, however, at the moment it returns something like:</p>
  
  <pre><code>/listings/free/None/None/
  </code></pre>
  
  <p>I would like, in this situation, to return:</p>
  
  <pre><code>/listings/free/
  </code></pre>
  
  <p>Is there a way around this, or a better way to do it that I'm missing?</p>