@require_GET
def topic_lookup(request):
 topiclist = []
 if request.is_ajax():
  topic = request.GET.get('topic', '')
  if topic:
   matches = Document.objects.filter(slug__icontains=topic)
   for match in matches:
    topiclist.append({'label': match.slug})
 data = json.dumps(topiclist)
 return HttpResponse(data, content_type='application/json; charset=utf-8')

@ require_GET def topic_lookup ( request ) : topiclist = [ ] if request . is_ajax ( ) : topic = request . GET . get ( 'topic' , '' ) if topic : matches = Document . objects . filter ( slug__icontains = topic ) for match in matches : topiclist . append ( { 'label' : match . slug } ) data = json . dumps ( topiclist ) return HttpResponse ( data , content_type = 'application/json; charset=utf-8' )
returns partial topic matches .