class Project(models.Model):
title = models.CharField()
class Job(models.Model):
name = models.CharField()
user = models.ForeignKey(User)
project = models.ForeignKey(Project)
I have many jobs for each project. How do i get a list of all users of all jobs of a project?
I came up with this:
users = set()
for job in project.job_set.all():
users.add(job.user)
Is there an easier way without explicitely looping through every job?