title: Django ajax url not reading
body: <p>I have an ajax file which calls the url from the <code>urls.py</code> which gets the json data from the <code>views.py</code> but when I run the server it just shows <code>Not Found:/dept-json/</code></p>
  <p>I did manage to get it to work using the django snippet <code>{% url 'accounts:dept-json'%}</code></p>
  <p>However I do not want this since I need to get and pass the variable from the <code>dept-json data</code> to another ajax url which is:</p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>url:`/prog-data/${selectedDept}/`</code></pre>
  </div>
  </div>
  </p>
  <p>I have read <a href="https://stackoverflow.com/questions/55051326/passing-a-parameter-through-ajax-url-with-django#:%7E:text=Votes-,3,POST%20you%20can%20send%20the%20ID%20in%20the%20posted%20data.,-Share">here</a> that you can't pass variables in ajax like  <code>{% url 'accounts:prog-json' department%}</code></p>
  <p>how do I manage to do this?</p>
  <blockquote>
  <p>here is my code:</p>
  </blockquote>
  <p><strong>main.js</strong></p>
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>//First ajax
  $.ajax({
      type: 'GET',
      url: "/dept-json/",
  //    url: "{% url 'accounts:dept-json'%}",
      success: function(response){
          console.log(response)
          },
          error: function(error){
          console.log(error)
      }
  })
  //Second ajax
  $.ajax({
      type: 'GET',
      url: `/prog-data/${selectedDept}/`,
      success: function(response){
          console.log(response)
          },
          error: function(error){
          console.log(error)
      }
  })</code></pre>
  </div>
  </div>
  </p>
  <p><strong>urls.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>    path('dept-json/', get_json_dept_data, name='dept-json'),
      path('prog-json/&lt;str:department&gt;/', get_json_prog_data, name='prog-json'),
  </code></pre>
  <p><strong>views.py</strong></p>
  <pre class="lang-py prettyprint-override"><code>def get_json_dept_data(request):
      qs_val = list(Department.objects.values())
      return JsonResponse({'data':qs_val})
  
  def get_json_prog_data(request, *args, **kwargs):
      selected_department = kwargs.get('department')
      obj_prog = list(Program.objects.filter(department__name=selected_department).values())
      return JsonResponse({'data':obj_prog})
  </code></pre>