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
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
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
3 matches
Mail list logo