title: Django JQuery autocomplete not working - nothing showing up, but API URL works
body: <p>I have tried to implement autocomplete exactly as this tutorial shows: <a href="https://www.youtube.com/watch?v=-oLVZp1NQVE" rel="nofollow noreferrer">https://www.youtube.com/watch?v=-oLVZp1NQVE</a></p>
  <p>Here is the tutorial code, which is very similar to what I have here: <a href="https://github.com/akjasim/cb_dj_autocomplete" rel="nofollow noreferrer">https://github.com/akjasim/cb_dj_autocomplete</a></p>
  <p>However, it is not working for me. The API url works, but nothing populates in the field, i.e. there is no autocomplete that shows up. What could I be doing wrong? I'm using yarn and yarn build and have collected static, but still does not work.</p>
  <p>Here is the jquery:</p>
  <pre><code> &lt;script src=&quot;https://code.jquery.com/jquery-1.12.4.js&quot;&gt;&lt;/script&gt;
      &lt;script src=&quot;https://code.jquery.com/ui/1.12.1/jquery-ui.js&quot;&gt;&lt;/script&gt;
      &lt;script&gt;
          $(function () {
              $(&quot;#product&quot;).autocomplete({
                  source: '{% url 'autocomplete' %}',
                  minLength: 2
              });
          });
      &lt;/script&gt;
  </code></pre>
  <p>Here is the html:</p>
  <pre><code>&lt;title&gt;Autocomplete&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;form&gt;
      &lt;label for=&quot;product&quot;&gt;Product&lt;/label&gt;
      &lt;input type=&quot;text&quot; name=&quot;product&quot; id=&quot;product&quot;&gt;
  &lt;/form&gt;
  </code></pre>
  <p>Here is the views:</p>
  <pre><code>def autocomplete(request):
      if 'term' in request.GET:
          qs = Model.objects.filter(title__icontains=request.GET.get('term'))
          titles = list()
          for product in qs:
              titles.append(product.title)
          # titles = [product.title for product in qs]
          return JsonResponse(titles, safe=False)
      return render(request, 'file_for_viewing.html')
  </code></pre>
  <p>Then here is the URL:</p>
  <pre><code>path('autocomplete',views.autocomplete, name='autocomplete'),
  </code></pre>
  <p>Even when source is a list, autocomplete not working:</p>
  <pre><code>source: '['chicago', 'new york',...,''] 
  </code></pre>
  <p>So the error is the request is getting canceled, because <code>XMLHttpRequest cannot load XXX due to access control checks.</code></p>