views:

129

answers:

1

Hi guys, i have a simple search in my project, but my project is in Spanish , we have a lot of word with accents, and my search dont bring this word with accents.... there's any django /python function for this?

view.py

def search(request):
    categorias = Categoria.objects.filter(parent__isnull=True) # menu
    query = request.GET.get('q')
    result = []
    if query:
            results = Noticia.objects.filter(body__icontains=query)
    return render_to_response('buscar/search.html',{'query':query,'results': results,'categorias':categorias},context_instance = RequestContext(request))

Thanks :)

+2  A: 

This is nothing to do with Django, but depends on the collation of your database tables. The collation is what determines how to sort and compare characters, and you need to choose one that compares accented and non-accented characters as equal. If you're using MySQL, a good collation would be utf8_general_ci.

Daniel Roseman
Thanks guy's my collation is utf8_general_ci
Asinox