Python Autocomplete Internal 500 error

I’m using a Python autocomplete plugin from bassistance.de but I’m receiving a 500 error when typing, instead of suggestions.

Firebug states a 500 while Python is reporting a name error at line 200 inside my views.py.

“global name ‘HttpResponse’ is not defined”

Error copied from Firebug:

GET http://127.0.0.1:8000/ajax/tag/autocomplete/?q=test&limit=10&timestamp=1262114752504
	
500 INTERNAL SERVER ERROR
		95ms

Here is my html:

{% block external %}
	<link rel='stylesheet' type='text/css' href='/site_media/jquery.autocomplete.css' />
	<script type='text/javascript' src='/site_media/jquery.autocomplete.js'></script>
	<script type='text/javascript' src='/site_media/tag_autocomplete.js'></script>
	<script type='text/javascript' src='/site_media/jquery.bgiframe.min.js'></script>
{% endblock %}

Here is a snippet from my views.py(line 200 is reporting “global name ‘HttpResponse’ is not defined”):

def ajax_tag_autocomplete(request):
	if 'q' in request.GET:
		tags = Tag.objects.filter(
			name__istartswith=request.GET['q']
		)[:10]
200.		return HttpResponse(u'\
'.join(tag.name for tag in tags))
	return HttpResponse()

Here is a snippet from my urls.py:

# Ajax
(r'^ajax/tag/autocomplete/$', ajax_tag_autocomplete),
)

Here is a snippet from my tag_autocomplete.js file:

$(document).ready(function () {
	$("#id_tags").autocomplete(
		'/ajax/tag/autocomplete/',
		{multiple: true, multipleSeparator: ' '}
	);
});

I have a feeling it’s something very obvious that I’m overlooking.

Thanks.

enable Django’s debug and you’ll get details debug information via Firebug

Looks like you’re missing

from django.http import HttpResponse

in your views.py.

THANK YOU! I knew it was something obvious like that. Works like a charm now. :rofl::lol::rofl::lol::rofl: