+def json_tags_starting_with(request, callback=None):
+ # Callback for JSONP
+ prefix = request.GET.get('q', '')
+ callback = request.GET.get('callback', '')
+ # Prefix must have at least 2 characters
+ if len(prefix) < 2:
+ return HttpResponse('')
+ tags_list = []
+ result = ""
+ for tag in _tags_starting_with(prefix, request.user):
+ if not tag.name in tags_list:
+ result += "\n" + tag.name
+ tags_list.append(tag.name)
+ dict_result = {"matches": tags_list}
+ return JSONResponse(dict_result, callback)
+