title: Create Django named URL using template variable?
body: <p>How do you specify a named URL pattern in Django if you need to pass it a template variable?  My template contains the following URL:</p>
  
  <pre><code># templates/welcome.html
  # Link to template that shows all members near member with this uid
  &lt;a href="{% url 'show-members-near' %}uid={{ uid }}"&gt;Show members near you&lt;/a&gt;
  </code></pre>
  
  <p>My top-level URLconf file contains the following pattern which points
  to the application-specific url file:</p>
  
  <pre><code># conf/urls.py
  urlpatterns = patterns('',
      ...
      url(r'^members/',            include('apps.members.urls')),
      ...
  )
  </code></pre>
  
  <p>Here is my application-specific url file:</p>
  
  <pre><code># app/members/url.py
  url(r'^near/(?P&lt;uid&gt;\d{1,})/$',
      'show_members',
      {'template': 'show_members.html'},
      name='show-members-near'),
  </code></pre>
  
  <p>This is the error I get:</p>
  
  <pre><code>NoReverseMatch at /personal_profile/welcome/
  Reverse for 'show-members-near' with arguments '()' and keyword arguments '{}' not found.  1 pattern(s) tried: ['members/near/(?P&lt;uid&gt;\\d{1})/$']
  </code></pre>
  
  <p>I tried to insert a keyword argument like this but it didn't work:</p>
  
  <pre><code>&lt;a href="{% url 'show-members-near' uid={{ uid }} %}"&gt;Show members near you&lt;/a&gt;
  </code></pre>
  
  <p>After doing some research, everything I read seemed to indicate that the keyword argument should be passed the way I did it up above.  What I'm trying to do is the equivalent of the following which <em>does</em> work:</p>
  
  <pre><code>&lt;a href="/members/near/{{ uid }}/"&gt;See who's here&lt;/a&gt;
  </code></pre>
  
  <p>How do I specify a keyword argument?  I didn't see anything that addresses this situation in the Django docs (although I might have missed it).</p>
  
  <p>Thanks!</p>