Jorge Machado Jorge Machado - 23 days ago 9
MySQL Question

Django queries Especial Characters

I Working on location from google maps and using django to. My question is:

I have a String in

request.GET['descricao']
lets say it contains "Via rapida".

In my database i have store = "Via Rápida" i'm doing :

local = Local.objects.filter(name__icontains=request.GET['descricao'])


with that i can get everthing fine like "Via Rapida" but the result that have "Via rápida" never get match in the query (ASCI character may be?)

what must i do given a string "Via rapida" match "via rápida" and "via rapida"? Regular Expressions? How?

Answer

I think the better way is to use a Full Text search engine , Here is a list of Full Text search engine that can be used with django :

And wee shouldn't forget Haystack which is a proxy that can use different search engine like solr, whoosh ...;

You can also use your database Full Text search without using a third library something like this.

EDIT: from the OP comment, the QuerySet API offer a full text search feature that work only with MySQL check here.