@treeio_login_required
def ajax_contact_lookup(request, response_format='html'):
 contacts = []
 if (request.GET and ('term' in request.GET)):
  user = request.user.profile
  contacts = Object.filter_permitted(user, Contact.objects, mode='x').filter(Q(name__icontains=request.GET['term']))[:10]
 return render_to_response('identities/ajax_contact_lookup', {'contacts': contacts}, context_instance=RequestContext(request), response_format=response_format)

@ treeio_login_required def ajax_contact_lookup ( request , response_format = 'html' ) : contacts = [ ] if ( request . GET and ( 'term' in request . GET ) ) : user = request . user . profile contacts = Object . filter_permitted ( user , Contact . objects , mode = 'x' ) . filter ( Q ( name__icontains = request . GET [ 'term' ] ) ) [ : 10 ] return render_to_response ( 'identities/ajax_contact_lookup' , { 'contacts' : contacts } , context_instance = RequestContext ( request ) , response_format = response_format )
returns a list of matching contacts .