diff -r 3743275f7291 -r 7c27e8d9231d project/kiwipycon/proceedings/views.py --- a/project/kiwipycon/proceedings/views.py Thu Jan 14 21:07:03 2010 +0530 +++ b/project/kiwipycon/proceedings/views.py Fri Jan 15 20:15:00 2010 +0530 @@ -1,8 +1,11 @@ # -*- coding: utf-8 -*- +import json from django.contrib.auth import login from django.contrib.auth.decorators import login_required from django.contrib.auth.forms import AuthenticationForm +from django.contrib.auth.models import User +from django.http import HttpResponse from django.shortcuts import render_to_response from django.template import RequestContext @@ -92,3 +95,19 @@ }) return render_to_response(template, context) + + +def getUsers(request): + """View function called by autocomplete jQuery plugin to get + the user names. + """ + + query = request.GET['query'] + suggestions = User.objects.filter(username__startswith=query) + + suggest_data = { + 'query': query, + 'suggestions':[user.username for user in suggestions], + } + + return HttpResponse(json.dumps(suggest_data)) \ No newline at end of file