Re: Imposing a negative constraint on related objects

2009-06-11 Thread Rowan Nairn

On Thu, Jun 11, 2009 at 9:15 AM, Jashugan  wrote:
>
> On Jun 10, 2:48 pm, Rowan  wrote:
>
>> Here is an English description of what I want to achieve:
>> "People who have received mails with tag T, excluding mails in threads
>> that they started themselves"
>
> Have you tried using Q objects?
>
> Person.objects.filter(
>    Q(received_mails__tags=T) & \
>    !Q(received_mails__thread__started_by=F('id'))).distinct()

Yes.  This produces exactly the same query as the one with exclude.

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Imposing a negative constraint on related objects

2009-06-11 Thread Jashugan

On Jun 10, 2:48 pm, Rowan  wrote:

> Here is an English description of what I want to achieve:
> "People who have received mails with tag T, excluding mails in threads
> that they started themselves"

Have you tried using Q objects?

Person.objects.filter(
Q(received_mails__tags=T) & \
!Q(received_mails__thread__started_by=F('id'))).distinct()
--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---