예제 #1
0
def band_search_json(request):
    q = request.GET['q']
    searchterm = normalize_string( q )

    if searchterm=='':
        matches = []
    else:
        bands = Band.objects.all().filter(name_normalized__startswith=searchterm)[:20]

        matches = [band.name for band in bands]

    resp_obj = {'q':q,'matches':matches}

    return HttpResponse( json.dumps(resp_obj) )
예제 #2
0
def person_search_json(request):
    q = request.GET['q']
    searchterm = normalize_string( q )

    if searchterm=='':
        matches = []
    else:
        people = Person.objects.all().filter(name_normalized__startswith=searchterm)[:20]

        matches = [person.name for person in people]

    resp_obj = {'q':q,'matches':matches}

    return HttpResponse( json.dumps(resp_obj) )
예제 #3
0
  def __init__(self, *args, **kwargs):
    models.Model.__init__(self, *args, **kwargs)

    self.name_normalized = normalize_string(self.name)
예제 #4
0
def fixbands(request):
    for band in Band.objects.all():
        band.name_normalized = normalize_string(band.name)
        band.save()

    return HttpResponse('success')
예제 #5
0
def fixpeople(request):
    for person in Person.objects.all():
        person.name_normalized = normalize_string(person.name)
        person.save()

    return HttpResponse('success')