title: Reversing Django URLs With Extra Options
body: <p>Suppose I have a URLconf like below, and <code>'foo'</code> and <code>'bar'</code> are valid values for <code>page_slug</code>.</p>
  
  <pre><code>urlpatterns = patterns('',
      (r'^page/(?P&lt;page_slug&gt;.*)/', 'myapp.views.someview'),
  )
  </code></pre>
  
  <p>Then, I could reconstruct the URLs using the below, right?</p>
  
  <pre><code>&gt;&gt;&gt; from django.core.urlresolvers import reverse
  &gt;&gt;&gt; reverse('myapp.views.someview', kwargs={'page_slug': 'foo'})
  '/page/foo/'
  &gt;&gt;&gt; reverse('myapp.views.someview', kwargs={'page_slug': 'bar'})
  '/page/bar/'
  </code></pre>
  
  <p>But what if I change my URLconf to this?</p>
  
  <pre><code>urlpatterns = patterns('',
      (r'^foo-direct/', 'myapp.views.someview', {'page_slug': 'foo'}),
      (r'^my-bar-page/', 'myapp.views.someview', {'page_slug': 'bar'}),
  )
  </code></pre>
  
  <p>I expected this result:</p>
  
  <pre><code>&gt;&gt;&gt; from django.core.urlresolvers import reverse
  &gt;&gt;&gt; reverse('myapp.views.someview', kwargs={'page_slug': 'foo'})
  '/foo-direct/'
  &gt;&gt;&gt; reverse('myapp.views.someview', kwargs={'page_slug': 'bar'})
  '/my-bar-page/'
  </code></pre>
  
  <p>However, this throws a <code>NoReverseMatch</code> exception. I suspect I'm trying to do something impossible. Any suggestions on a saner way to accomplish what I want?</p>
  
  <p>Named URLs aren't an option, since I don't want other apps that link to these to need to know about the specifics of the URL structure (encapsulation and all that).</p>