1π
I, playing django now, interprete your query as:
Give me all Jobs that has a picture from picture_job_sets, inasmuch as
one of the pictures is marked as main picture.
So like you said, it returns all the pictures for each job in the list view if the condition is met for any of the pictures.
Quoting you: there will always only be one main picture for each job. If there will always be a main picture, you can easily start the query from the pictures:
Picture.objects.filter(is_main_pic=True).select_related(βJobβ)
Then you can iterate over each picture and do .job on each to get the related job.
One last thing though, I suspect you have this problem because of your design. Wonβt you have a simpler design if you move a main picture as a field to your Job model?