title: Jquery Autocomplete with Django
body: <p>I'm trying to make a search of some items with a jquery ui autocomple in a django app. I have looked at this <a href="https://stackoverflow.com/questions/4920031/jquery-autocomplete">question</a>, and I'm following just like autocomplete doc. I'm not interested in plugins or something else. I got this.</p>
  
  <p>In views.py:</p>
  
  <pre><code>def search_view(request):
      q = request.GET['term']
      ret = []
      listado = Model.objects.filter(descripcion__istartswith=q).order_by("descripcion")
      for l in listado:
          ret.append({'label':l.descripcion, 'value':l.id})
      return HttpResponse(simplejson.dumps(ret), mimetype='application/json')
  </code></pre>
  
  <p>In my template, I have something like this</p>
  
  <p>the js:</p>
  
  <pre><code>$("#auto_material").autocomplete({
                  source:'{% url search_view %}',
                  minLength: 2,
                  select: function( event, ui ) {
                      $("#auto_material").val(ui.item.label);
                      $("#id_material").val(ui.item.value);
                  }
  
              });
  </code></pre>
  
  <p>the html:</p>
  
  <pre><code>&lt;input type="text" id="auto_material" name="material" class="campo" style="width:99%;"/&gt;
  &lt;input type="hidden" id="id_material" /&gt;
  </code></pre>
  
  <p>Everything in the search of items works fine, but when I'm trying to set the text input value with the ui.item.label it keeps putting the ui.item.value on the text input, not the label. </p>
  
  <p>Any idea? Is the "select" event on the autocomplete object overridable? Any idea?</p>
  
  <p>Thanks in advance.</p>