Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Jonty Needham
Thanks :-) Should have guessed it was that easy! On Wed, Dec 23, 2015 at 12:44 PM, Vijay Khemlani 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) > > > O

Re: Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Vijay Khemlani
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 wrote: > I have a model of the form: > > class Jobs(models.Model): >

Fitering on manytomany field whose results are contained within another set...

2015-12-23 Thread Jonty Needham
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