Re: more than one querys LIKE in the same field

2010-12-14 Thread Łukasz Rekucki
On 14 December 2010 09:10, marcoarreguin wrote: > Hi friends! > > I mean do something like this: > > SELECT * FROM table WHERE tags LIKE '%candy%' AND  tags LIKE '%milk%' > > > I've tried: > > table.objects.filter(tags__icontains='candy', tags__icontains='milk') > > I've

Re: more than one querys LIKE in the same field

2010-12-14 Thread Chris Lawlor
Not to second guess your intent, but are you sure you don't mean to OR the two? Your current SQL / Django query will only return tags that have both 'candy' and 'milk' in the tags string. If you do want to OR the queries, you can use Q objects: from django.db.models import Q

more than one querys LIKE in the same field

2010-12-14 Thread marcoarreguin
Hi friends! I mean do something like this: SELECT * FROM table WHERE tags LIKE '%candy%' AND tags LIKE '%milk%' I've tried: table.objects.filter(tags__icontains='candy', tags__icontains='milk') I've tried too: list = ['candy', 'milk'] table.objects.filter(tags__icontains=list And nothing