title: Pass a template variable to django url using jquery
body: <p>Is it possible to pass a template variable to a django url with jquery? I've tried the standard way of passing the parameter to the django url, but I get a no reverse match.</p>
  
  <p><strong>Javascript</strong></p>
  
  <pre><code>&lt;button id = "testid" href = "{%url 'test:justatest' id=8}"&gt;Click here for something&lt;/button&gt;
  
  &lt;script type="text/javascript"&gt;
    var btn = $('#testid');
  
        btn.click(function (e) {
          var goto = $(this).attr('href');
            e.preventDefault();
  
      $.ajax({ 
      url: goto, 
      type: "GET",
      success: function(data){
          console.log(data);
          alert(data);
      }});
  });
  
    &lt;/script&gt;
  </code></pre>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>path('test/&lt;int:id&gt;',views.TestDetail.as_view(),name="justatest")
  </code></pre>
  
  <p>I also tried this based off
  <a href="https://stackoverflow.com/questions/4591525/is-it-possible-to-pass-query-parameters-via-djangos-url-template-tag?noredirect=1&amp;lq=1">this post</a> but I just get a 404.</p>
  
  <pre><code>&lt;button id = "testid" href = "{%url 'test:justatest'%?id=8}"&gt;Click here for something&lt;/button&gt;
  
  &lt;script type="text/javascript"&gt;
    var btn = $('#testid');
  
        btn.click(function (e) {
          var goto = $(this).attr('href');
            e.preventDefault();
  
      $.ajax({ 
      url: goto, 
      type: "GET",
      success: function(data){
          console.log(data);
          alert(data);
      }});
  });
  
    &lt;/script&gt;
  </code></pre>