title: django-autocomplete-light tutorial: select2 is not a function error
body: <p>I was having trouble while using <a href="https://github.com/yourlabs/django-autocomplete-light" rel="noreferrer">dal</a> and tried to build a simple example.</p>
  
  <p>I did almost the exactly the same as <a href="https://stackoverflow.com/questions/36032372/django-autocomplete-light-field-not-populated/36150896">Django autocomplete light: field not populated</a> and also applied the answer of the link.</p>
  
  <p>Here are the steps I went through:</p>
  
  <p>Step 1) When I add like this on header of html (just the same as the above answer):</p>
  
  <pre><code>    &lt;link href="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/vendor/select2/dist/css/select2.css" type="text/css" media="all" rel="stylesheet" /&gt;
      &lt;link href="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/select2.css" type="text/css" media="all" rel="stylesheet" /&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/autocomplete.init.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/select2.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>The error of browser inspector console is like this:</p>
  
  <pre><code>Uncaught ReferenceError: yl is not defined(anonymous function) @ autocomplete.init.js:75select2.js:117 
  Uncaught ReferenceError: yl is not defined(anonymous function) @ select2.js:117
  </code></pre>
  
  <p>Step 2) So I added jquery.js and other js files on the dal library:</p>
  
  <pre><code>    &lt;link href="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/vendor/select2/dist/css/select2.css" type="text/css" media="all" rel="stylesheet" /&gt;
      &lt;link href="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/select2.css" type="text/css" media="all" rel="stylesheet" /&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/admin/js/vendor/jquery/jquery.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/admin/js/jquery.init.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/jquery.init.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/autocomplete.init.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/autocomplete_light/select2.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>And the error changed like this:</p>
  
  <pre><code>select2.js:66 Uncaught TypeError: $(...).select2 is not a function(anonymous function) @ select2.js:66dispatch @ jquery.js:4435elemData.handle @ jquery.js:4121trigger @ jquery.js:4350(anonymous function) @ jquery.js:4901each @ jquery.js:374each @ jquery.js:139trigger @ jquery.js:4900initialize @ autocomplete.init.js:45each @ jquery.js:374each @ jquery.js:139(anonymous function) @ autocomplete.init.js:50fire @ jquery.js:3099fireWith @ jquery.js:3211ready @ jquery.js:3417completed @ jquery.js:3433
  </code></pre>
  
  <p>Step 3) And for the last, I found these two plugins and added and it worked!</p>
  
  <pre><code>    Plugins of [Step 2)] + 
      &lt;link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css" rel="stylesheet" /&gt;
      &lt;script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>So here are my questions:</p>
  
  <p>A) Should I add all the plugins above? For example, there are two select2.js on the plugins of [step 3)] and I'm confused and wonder if they work on different ways.(If I remove one of them, it doesn't work.)</p>
  
  <p>B) According to the question <a href="https://stackoverflow.com/questions/36032372/django-autocomplete-light-field-not-populated/36150896">Django autocomplete light: field not populated</a>, shouldn't step 2 work? Why does it occur the error?</p>
  
  <p>C) On this sample code, the part of following code seems not working at all. If not with admin account, the foreign key doesn't appears on the text field, in other words, nothing can be found on the list. (from the <a href="http://django-autocomplete-light.readthedocs.io/en/master/tutorial.html" rel="noreferrer">dal tutorial</a>, it allows 'Using autocompletes outside the admin')</p>
  
  <pre><code>{% block footer %}
  &lt;script type="text/javascript" src="http://dal-yourlabs.rhcloud.com/static/collected/admin/js/vendor/jquery/jquery.js"&gt;&lt;/script&gt;
  {{ form.media }}
  {% endblock %}
  </code></pre>
  
  <p>@ I also checked <a href="https://stackoverflow.com/questions/37143571/django-autocomplete-light-not-working-select2-is-not-a-function">django-autocomplete-light not working - select2 is not a function</a> and rearrange the installed app didn't work.</p>