def version_autocomplete(request, project_slug):
 queryset = Project.objects.public(request.user)
 get_object_or_404(queryset, slug=project_slug)
 versions = Version.objects.public(request.user)
 if ('term' in request.GET):
  term = request.GET['term']
 else:
  raise Http404
 version_queryset = versions.filter(slug__icontains=term)[:20]
 names = version_queryset.values_list('slug', flat=True)
 json_response = json.dumps(list(names))
 return HttpResponse(json_response, content_type='text/javascript')

def version_autocomplete ( request , project_slug ) : queryset = Project . objects . public ( request . user ) get_object_or_404 ( queryset , slug = project_slug ) versions = Version . objects . public ( request . user ) if ( 'term' in request . GET ) : term = request . GET [ 'term' ] else : raise Http404 version_queryset = versions . filter ( slug__icontains = term ) [ : 20 ] names = version_queryset . values_list ( 'slug' , flat = True ) json_response = json . dumps ( list ( names ) ) return HttpResponse ( json_response , content_type = 'text/javascript' )
return a json list of version names .