title: how to filter a django query set by a foreign key in restful framework?
body: <p>i met a problem when using django + restful framework.</p>
  
  <p>here is my intention:</p>
  
  <p>there are many chapters, each chapter has many words, each word has many expand explanations, these explanations are offered by users, so some of them are invaild, in the backend i can set these expands' field <strong>is_alive</strong> to <strong>False</strong>.</p>
  
  <p>in the <strong>views.py</strong>, currently i send all these data to frontend, i tried many ways to filter these invaild data out, but failed.</p>
  
  <p>here are codes:</p>
  
  <p><strong>models.py</strong></p>
  
  <pre><code>class Chapter(models.Model):
      chap = models.IntegerField('chaptername')
  
  class Word(models.Model):
      chapter = models.ForeignKey('Chapter', related_name='voca')
      word = models.CharField('name', max_length=255)
  
  class Expand(models.Model):
      belong = models.ForeignKey('Word', related_name='expand')
      explansion = models.TextField('description')
      is_alive = models.BooleanField('status', default=True)
  </code></pre>
  
  <p><strong>serializers.py</strong></p>
  
  <pre><code>class ExpandSerializer(serializers.ModelSerializer):
      class Meta:
          model = Expand
          fields = ('explansion', )
  
  class WordSerializer(serializers.ModelSerializer):
      expand = ExpandSerializer(many=True)
  
      class Meta:
           model = Word
           fields = ('id', 'word', 'expand')
  
  class ChapterSerializer(serializers.ModelSerializer):
      voca = WordSerializer(many=True)
  
      class Meta:
          model = Chapter
          fields = ('id', 'chap', 'voca')
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def getChapter(request):
  
      if request.method == 'GET':
  
          chapter = Chapter.objects.get(pk=1)
          serializer_c = ChapterSerializer(chapter)
          return JsonResponse(serializer_c.data)
  </code></pre>