Custom Search

Monday, June 7, 2010

django like query customize

As start I know there is __contains.
But it only does LIKE '%word%'query.

I want to do LIKE '%word1%word2%' query.

for e.g. select * from table where column LIKE '%ipod%nano%'.

Try using 2 %'s in your query
like this:
CLASSNAME.objects.raw("select * from table where full_name like
'%%ipod%%nano%%' ")

No comments:

Post a Comment