title: Filtered Nested Relationships Django Rest Framework
body: <p>I have two models which look like the following:</p>
  
  <pre><code>class Subject(models.Model):
  
     subject_code = models.CharField(max_length=12, unique=True)
     name = models.CharField(max_length=100)
     dept_code = models.CharField(max_length=6)
  </code></pre>
  
  <p>and...</p>
  
  <pre><code>class Subject_assessment(models.Model):    
     subject_code = models.ForeignKey(Subject, related_name='sub_assessments')
     year = models.CharField(max_length=4)
     name = models.CharField(max_length=50)
  </code></pre>
  
  <p>I have created my serializes in such a way that when I retrieve a subject, I also retrieve the assessments associated with that subject. I am using the following serializers to accomplish this:</p>
  
  <pre><code>class AssessmentsSerializer(serializers.ModelSerializer):
  class Meta:
      model = Subject_assessment
      fields = (
          "subject_code", "year", "name"
      )
  
  class SubjectSerializer(serializers.ModelSerializer):
  sub_assessments = AssessmentsSerializer(many=True)
  class Meta:
      model = Subject
      fields = (
          "subject_code", "name", "dept_code",            
          "sub_assessments"
      )
  </code></pre>
  
  <p>This code works perfectly as anticipated as it gives me a result like this:</p>
  
  <pre><code>{
   "subject_code":"ECR2243",
   "name":"Statistics",
   "dept_code":"Stats",
   "sub_assessments":[
       {
         "subject_code":"ECR2243",
         "year":"2017",
         "name":"Test 1"
       },
       {
         "subject_code":"ECR2243",
         "year":"2016",
         "name":"Test 1"
       }
   ]
  }
  </code></pre>
  
  <p>My problem is that I wish to retrieve assessments only for a specific year. For example, If I pass <strong>2017</strong> as the year of interest, I do not wish to retrieve assessments for <strong>2016</strong> like I am currently getting.</p>
  
  <p>Can anyone please assist on how I can structure my code in order to accomplish this. Thank you in advance.</p>
  
  <hr>
  
  <p><strong>Edit 1</strong>
  My views.py is as follows:</p>
  
  <pre><code>class  SubjectViewSet(viewsets.ModelViewSet):
  serializer_class = SubjectSerializer
  lookup_field = 'subject_code'
  
  def get_queryset(self):
      qry_subject_code = self.request.GET.get('subject_code')
      retrieved_sub = Subject.objects.filter(subject_code=qry_subject_code)
      return retrieved_sub
  </code></pre>