title: Filter list view based on foreign key of another model
body: <p>I have three models, subjects, topics and study days. I want to display the study days in a list view but just show study days with different topics connected to the same subject.</p>
  <p>This is my model structure</p>
  <pre><code>class Subject(models.Model):
      name = models.CharField(max_length=100, null=False)
  
   
  class Topic(models.Model):
      subject = models.ForeignKey(Subject, on_delete=models.CASCADE)
      name = models.CharField(max_length=100, null=False)
  
   
  class StudyDay(models.Model):
      student = models.ForeignKey(User, on_delete=models.CASCADE)
      topic = models.ForeignKey(Topic, on_delete=models.CASCADE)
      ...
      
  </code></pre>
  <p>I have tried this in one of the views and it filters correctly but it removes the data previously showing up associated with the study day, so it does not work correctly.</p>
  <pre><code>def get_context_data(self, **kwargs):
          context = super().get_context_data(**kwargs)
          context['study'] = context['study'].filter(student=self.request.user)
          context['study'] = Topic.objects.filter(subject=3) # This is the line where I try to filter
          return context
  </code></pre>
  <p>So the question is, is there any way for me to filter through the objects in the StudyDay model based on which subject the topic in the study day belongs to?</p>