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
table.objects.filter(Q(tags__icontains='milk') |
Q(tags__icontains='candy'))

Also note that, if you're using sqlite, case-insensitive string
lookups are not supported (see 
http://docs.djangoproject.com/en/dev/ref/databases/#sqlite-string-matching).

Hope this is helpful,

Chris

On Dec 14, 3:10 am, marcoarreguin <marcoarreg...@gmail.com> 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 tried too:
>
> list = ['candy', 'milk']
> table.objects.filter(tags__icontains=list
>
> And nothing work. Help me please :s
>
> Thanks bros!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to