title: Django rest ModelViewSet filtering objects
body: <p>I have two models: Library and a Book. A Library will have Many Books.</p>
  
  <pre><code>class Library(models.Model):
      library_id = models.AutoField(primary_key=True)
      name = models.CharField(max_length=30)
      city = models.CharField(max_length=30)
      address = models.CharField(max_length=80)
      phone = models.CharField(max_length=30, blank=True, null=True)
      website = models.CharField(max_length=60, blank=True, null=True)
  
  class Book(models.Model):
      book_id = models.AutoField(primary_key=True)
      title = models.CharField(max_length=30)
      # A library has many books
      which_library = models.ForeignKey('Library', related_name='books', on_delete=models.CASCADE)
      reader = models.ManyToManyField('Reader', related_name='wishlist')
  </code></pre>
  
  <p>my serializers:</p>
  
  <pre><code>class LibrarySerializer(serializers.ModelSerializer):
      class Meta:
          model = Library
          fields = '__all__'
  
  class BookSerializer(serializers.ModelSerializer):
  
      wishlist = ReaderSerializer(many=True, read_only=True)
  
      class Meta:
          model = Book
          fields = '__all__'
  </code></pre>
  
  <p>And my view:</p>
  
  <pre><code>class LibraryViewSet(viewsets.ModelViewSet):
      queryset = Library.objects.all()
      serializer_class = LibrarySerializer
  
  class BookViewSet(viewsets.ModelViewSet):
      queryset = Book.objects.filter(which_library=library_id)
      serializer_class = BookSerializer
  </code></pre>
  
  <p>My Urls:</p>
  
  <pre><code>router = routers.DefaultRouter()
  router.register(r'libraries', LibraryViewSet)
  router.register(r'books/(?P&lt;library_id&gt;[0-9]+)', BookViewSet)
  
  urlpatterns = router.urls
  </code></pre>
  
  <p>my Library routes work correct. However for Books, I need to return the books only belonging to specific library. The default URL and all() returns all the books in database and can retrieve single by hitting <code>books/1</code>.   </p>
  
  <p>How can I achieve this? I could do it previously with :</p>
  
  <pre><code>@api_view(['GET', 'POST'])
  def books(request, library_id): 
  </code></pre>
  
  <p>but now I want to do it with ModelViewSet.</p>