def autocomplete(request): import pprint test = Search([], "abc xyz def action") response = pprint.pformat([[obj.__str__() for obj in l] for l in test.autoComplete(10)]) return HttpResponse(response)
def get(self, request): query = request.GET.getlist('query') try: search = Search.fromJSON(query) except ValueError as e: return HttpResponseBadRequest("Bad request: %s" % e) completed = search.autoComplete(10) # TODO remove magic number result_list = [[block.as_list() for block in suggestion] for suggestion in completed] return self.render_to_response(result_list)