Fetching objects in complex through relationship Django
<p>I have been trying numerous things to solve the following in Django object filtering but thus no luck.</p>

<p>Utalizing a primary key for an individual, I would like to build an object list of all their milestones. </p>

<p>My models are laid out as such:</p>

<pre><code>TEAM MEMBER -- owns many tasks through --&gt; OWNER -- -- &gt; TASKS -- each task has multiple milestones --&gt; MILESTONES
</code></pre>

<p>The models are shown below:</p>

<pre><code>class TeamMember(models.Model):
    member_name = models.CharField(max_length=140)
    email = models.EmailField()
    task= models.ManyToManyField(Task, through='Owner')

class Owner(models.Model):
    teammember = models.ForeignKey(TeamMember, on_delete=models.CASCADE) 
    task = models.ForeignKey(Task, on_delete=models.CASCADE)

class Task(models.Model):
    task_name = models.CharField(max_length=140)
    task_description = models.TextField(null=True, blank=True)
    last_updated = models.DateTimeField(null=True, blank=True)

class Milestone(models.Model):
    name = models.CharField(max_length=140)
    task= models.ForeignKey(Task, on_delete=models.CASCADE)
    expected_date = models.DateTimeField()
</code></pre>

<p>The following doesnt work for me:</p>

<pre><code>Milestones.objects.filter(teammember__id)
</code></pre>

<p>Any ideas?</p>