Thanks Tim, works like a charm.
/L

Tim Chase wrote:
>> when combining Django ORM criteria you get
>> the "...WHERE...AND..." clauses.
>>
>> How do I get the "...WHERE...OR..." clauses?
>>
>> Resorting to raw SQL?
> 
> 
> Use Q objects and OR them together:
> 
> http://www.djangoproject.com/documentation/models/or_lookups/
> 
> 
> Foo.objects.filter(
>    Q(field1='baz') |
>    Q(field1='bar') |
>    Q(field2='spatula')
>    )
> 
> 
> They should be groupable as well, so you can use
> 
>    filter(
>      (Q(field1='foo') & Q(field2='bar'))
>      | Q(field1='baz')
>      )
> 
> -tim
> 
> 
> 
> 
> > 
> 



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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