# JQuery and Django Autocomplete

DevFeed: [JQuery and Django Autocomplete](<https://devfeed.tech/articles/jquery-and-django-autocomplete-41095.md>)

Original publisher: [Read original article](<https://www.craigkerstiens.com/2011/02/25/JQuery-and-Django-Autocomplete/>)

Author: Map

Published: 2011-02-26T03:55:56Z

Content type: tutorial

Language: en

Sources: [Craig Kerstiens](<https://devfeed.tech/sources/craig-kerstiens.md>)

Topics: [Django](<https://devfeed.tech/topics/django.md>), [jQuery](<https://devfeed.tech/topics/jquery.md>), [web applications](<https://devfeed.tech/topics/web-applications.md>), [JSON](<https://devfeed.tech/topics/json.md>), [callback](<https://devfeed.tech/topics/callback.md>)

Tags: [autocomplete](<https://devfeed.tech/tags/autocomplete.md>), [business](<https://devfeed.tech/tags/business.md>), [callback](<https://devfeed.tech/tags/callback.md>), [django](<https://devfeed.tech/tags/django.md>), [filter](<https://devfeed.tech/tags/filter.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [json](<https://devfeed.tech/tags/json.md>), [python](<https://devfeed.tech/tags/python.md>)

## AI overview

A concise tutorial showing how to add lightweight autocomplete to a Django web application using a Django view, model filtering, JSON responses, callbacks, and jQuery autocomplete.

## Source excerpt

In a couple of various places I've seen light requests of how to put autocomplete in for a Django web application. Here's a really light weight version with a view and autocomplete functionality using: from django.utils import simplejson def autocompleteModel(request): search_qs = ModelName.objects.filter(name__startswith=request.REQUEST['search']) results = [] for r in search_qs: results.append(r.name) resp = request.REQUEST['callback'] + '(' + simplejson.dumps(result) + ');' return HttpResponse(resp, content_type='application/json') For the jQuery autocomplete and call: