title: Using the Django URL Tag in an AJAX Call
body: <p>There are LOTS of post and pages discussing the use of Django and AJAX, and I've read hundreds over the past day or so looking for the answer to this question. A quick overview:</p>
  <p>May of the examples show a hard-coded URL like this:</p>
  <pre><code>$.post(&quot;/projects/create/&quot;, {&quot;name&quot; : name}, function(data) {...
  </code></pre>
  <p>or some use the URL template tag, but with no parameters:</p>
  <pre><code>$.post(&quot;{% url create_project %}&quot;, {&quot;name&quot; : name}, function(data) {...
  </code></pre>
  <p>However, I'd like to include a Django-style parameter in a URL.  Here's my url definition:</p>
  <pre><code>url(r'ajax/entity_name/(?P&lt;pk&gt;\w+)/$',EntityAjaxView.as_view(),name='entity_name'),
  </code></pre>
  <p>Yes, I'm using a class based view, and it is based on DetailView.  This view looks by default for a pk value to be provided in the URL, and in a normal template I would use:</p>
  <pre><code>{% url entity_name id_number %}
  </code></pre>
  <p>to provide a link.  In my code, I want to grab the value entered in an input box for the pk value.  Here is a snippet of my JavaScript (which doesn't work):</p>
  <pre><code>var id_number = $('#id_endowmententity_set-' + rownum + '-id_number').val()
  $.ajax({
      type: &quot;GET&quot;,
  url: '{% url entity_name id_number %}',
  </code></pre>
  <p>So, my question is, can I use the URL template tag with a value from an input box?</p>
  <p>(I know that I could use POST instead of GET and pass the id_number in the POST data, but that won't work well with the DetailView.)</p>