Thanks :-) Should have guessed it was that easy!

On Wed, Dec 23, 2015 at 12:44 PM, Vijay Khemlani <[email protected]> wrote:

> You should be able to query it as a ForeignKey
>
> Jobs.objects.filter(names__is_a_problem=True).distinct()
>
> (distinct to prevent repeated jobs with more than one worker problem)
>
>
> On Wed, Dec 23, 2015 at 9:31 AM, Jonty Needham <[email protected]>
> wrote:
>
>> I have a model of the form:
>>
>> class Jobs(models.Model):
>>         names  = models.ManyToManyField(Workers)
>>
>> class Workers(modesl.Model):
>>      is_a_problem = True
>>
>>
>> And I want the set of jobs that are done by workers who are a problem.
>>
>> Something like
>>
>>
>> Jobs.objects.filter(names__is_contained_in=Workers.objects.filter(is_a_problem=True))
>>
>> Obviously is_contained_in is not a valid lookup, so I would like to know
>> how to do this please.
>>
>> Thanks
>> Jonty
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To post to this group, send email to [email protected].
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CANOQRbz0TH53ix2hOCE7w8GkJMKPSB0utpzZgDzrAdXqn-Xzgw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CANOQRbz0TH53ix2hOCE7w8GkJMKPSB0utpzZgDzrAdXqn-Xzgw%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CALn3ei3oS0umn5u3T7QBpuK6LSJ716gMtp2cT8op9A1tnXp2FA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALn3ei3oS0umn5u3T7QBpuK6LSJ716gMtp2cT8op9A1tnXp2FA%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CANOQRbzzLGXXvjzVvUA9yS1keTchYpDHZ4yCWVfQtKTAcL7arA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to