@require_GET
def user_lookup(request):
 userlist = []
 if request.is_ajax():
  user = request.GET.get('user', '')
  if user:
   matches = get_user_model().objects.filter(username__istartswith=user)
   for match in matches:
    userlist.append({'label': match.username})
 data = json.dumps(userlist)
 return HttpResponse(data, content_type='application/json; charset=utf-8')

@ require_GET def user_lookup ( request ) : userlist = [ ] if request . is_ajax ( ) : user = request . GET . get ( 'user' , '' ) if user : matches = get_user_model ( ) . objects . filter ( username__istartswith = user ) for match in matches : userlist . append ( { 'label' : match . username } ) data = json . dumps ( userlist ) return HttpResponse ( data , content_type = 'application/json; charset=utf-8' )
returns partial username matches .