title: Django - Select2 Lookup no ajax request
body: <p>I am trying to use select2 to do ajax lookups within my app. On the form template I have the following code:</p>
  
  <pre><code>&lt;input class="form-control select2-hidden-accessible" id="id_tag_fk" name="tag_fk" placeholder="Tag fk" required="true" type="text" tabindex="-1" aria-hidden="true"&gt;
  
  &lt;script src="//cdnjs.cloudflare.com/ajax/libs/select2/4.0.0/js/select2.full.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript"&gt;
    $('#id_tag_fk').select2({
    ajax: {
      url: "http://localhost:8000/taglookup",
      dataType: 'json',
      delay: 250,
      data: function (params) {
        return {
          q: "one", // search term
        };
      },
      processResults: function (data, page) {
        // parse the results into the format expected by Select2.
        // since we are using custom formatting functions we do not need to
        // alter the remote JSON data
        return {
          results: data.items
        };
      },
      cache: true
    },
    escapeMarkup: function (markup) { return markup; }, // let our custom formatter work
    minimumInputLength: 1,
    templateResult: formatRepo,
    templateSelection: formatRepoSelection
  
  });
      function formatRepo (repo) {
      if (repo.loading) return repo.text;
  
      var markup = '&lt;div class="clearfix"&gt;' +
      '&lt;div class="col-sm-1"&gt;' +
      '&lt;img src="' + repo.owner.avatar_url + '" style="max-width: 100%" /&gt;' +
      '&lt;/div&gt;' +
      '&lt;div clas="col-sm-10"&gt;' +
      '&lt;div class="clearfix"&gt;' +
      '&lt;div class="col-sm-6"&gt;' + repo.full_name + '&lt;/div&gt;' +
      '&lt;div class="col-sm-3"&gt;&lt;i class="fa fa-code-fork"&gt;&lt;/i&gt; ' + repo.forks_count + '&lt;/div&gt;' +
      '&lt;div class="col-sm-2"&gt;&lt;i class="fa fa-star"&gt;&lt;/i&gt; ' + repo.stargazers_count + '&lt;/div&gt;' +
      '&lt;/div&gt;';
  
      if (repo.description) {
        markup += '&lt;div&gt;' + repo.description + '&lt;/div&gt;';
      }
  
      markup += '&lt;/div&gt;&lt;/div&gt;';
  
      return markup;
    }
  
      function formatRepoSelection (repo) {
      return repo.full_name || repo.text;
    }
  </code></pre>
  
  <p>Then I have my urls.py:</p>
  
  <pre><code>url(r'^taglookup/$', views.tag_lookup, name='tag-lookup'),
  </code></pre>
  
  <p>and my views.py: </p>
  
  <pre><code>def tag_lookup(request):
      print "IN HERE HERE"
      # do something with the your data
      data = {'items':['a','b','c']}
  
      # just return a JsonResponse
      return JsonResponse(data)
  </code></pre>
  
  <p>I do not get any terminal errors, or any console errors, but I dont get any prints in the terminal, and also it looks like there are no requests going out from the browser DevConsole-Network tab. 
  The select2 searchfield just shows: no resutls found.</p>
  
  <p>I cannot see why this is not working, any suggestions?</p>
  
  <p><strong>Update</strong> </p>
  
  <p>The following ajax call is working after some CSP changes..</p>
  
  <pre><code> $.ajax({
      type: "GET",
      url:"/taglookup",
      data: {
      'zip': 'twwas',
      },
      success: function(data){            
          alert("SUCCESS")
  
      },
      error: function(){
          alert("Error");
      },
    });
  </code></pre>