title: Send a queryset from Django views to JQuery
body: <p>I want to send a JsonResponse of a queryset from Django views to JQuery but I am not getting any data from the JQuery side.</p>
  <p>This is my views file <code>add_field_views.py</code> :</p>
  <p>from django.http import  JsonResponse</p>
  <pre><code>def drop_down_requests(request):
      text = request.POST['text']
      print(&quot;----&gt;&quot;, text)
      from captiq.financing_settings.models import ChoiceGroup
      response = ChoiceGroup.objects.get(slug=&quot;Ja/Nein&quot;)
      output = JsonResponse(response,safe=False)
      print(&quot;output -&quot;, output)
      return output
  </code></pre>
  <p>this is where I declared the URL in <code>urls.py</code> inorder for the Jquery to GET the data from the views :</p>
  <pre><code>urlpatterns = [
     
      path('my-ajax-test/', add_field_views.drop_down_requests, name='ajax-test-view'),
  ]
  </code></pre>
  <p>project <code>urls.py</code>:</p>
  <pre><code>frontend_urls = []
  for module_name, module_data in FRONTEND_MODULES.items():
      frontend_urls.append(re_path(
          module_data['url'],
          XFrameSameOriginView.as_view(template_name=module_data['view']),
          name=module_name))
  
  urlpatterns = i18n_patterns(
      path('admin/', admin_site.urls),
      path('admin/log_viewer/', include(
          ('log_viewer.urls', 'log-viewer'), namespace='log-viewer')),
      path('admin/docs/', include('docs.urls')),
      path('_nested_admin/', include('nested_admin.urls')),
      path('accounts/', include(
          ('accounts.urls', 'accounts'), namespace='accounts')),
      path('api-auth/',
           include('rest_framework.urls', namespace='rest_framework')),
  
  )
  
  api_v1_patterns = [
      path('financing/', include(
          ('financing.urls', 'financing'), namespace='financing')),
      path('financing-settings/', include(
          ('financing_settings.urls', 'financing_settings'),
          namespace='financing_settings')),
      path('partners/', include(
          ('partners.urls', 'partners'), namespace='partners')),
      path('accounts/', include(
          ('accounts.urls', 'accounts'), namespace='accounts')),
      path('customers/', include(
          ('customers.urls', 'customers'), namespace='customers')),
  ]
  
  urlpatterns += [
      path('api/v1/', include((api_v1_patterns, 'api'), namespace='api')),
      path('', RedirectView.as_view(url='loan-application/auth')),
      path('notifications/', include(
          'notifications.urls', namespace='notifications')),
  ] + frontend_urls
  
  if settings.ENABLE_ROSETTA:
      urlpatterns += i18n_patterns(
          path('admin/rosetta/', include('rosetta.urls')),
      )
  
  if settings.DEBUG:
      urlpatterns += static(
          settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  <p>then is my JQuery which is waiting for the queryset data or JSON data :</p>
  <pre><code>window.addEventListener('load', function () {
      (function ($) {
          &quot;use strict&quot;;
          $(document).ready(function () {
  
              $(&quot;#id_depending_field&quot;).change(function (event) {
                  console.log(&quot;am here man&quot;);
                  const valueSelected = this.value;
                  $.ajax({
                      type: &quot;POST&quot;,
                      url: 'my-ajax-test/',
                      data: {
                          csrfmiddlewaretoken:
                          document.getElementsByName('csrfmiddlewaretoken')[0].value,
                          text: valueSelected
                      },
                      success: function callback(response) {
                          console.log(&quot;____________&quot;, response)
                      }
                  });
              })
  
          });
      })(django.jQuery);
  });
  </code></pre>
  <p>With the code above am not able to get JSON data in JQuery, Instead I get a weird HTML output below :</p>
  <pre><code>&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/static/css/notifications.css&quot;&gt;
  
  .
                  
              
  </code></pre>
  <p>What am I doing wrong here ?</p>