title: django rest-farmework nested relationships to pass parameters
body: <p>Using django rest-farmework to implement the API,There is a problem has been unable to solve: How to pass parameters through the view.py to serializers.py? the specific code is as follows:</p>
  
  <p>models.py</p>
  
  <pre><code>class Category(models.Model):
      name = models.CharField(max_length=30)
      amount = models.IntegerField()
  
  class Source(models.Model):
      name = models.CharField(max_length=50)
      rss_link = models.URLField()
      amount = models.IntegerField()
      # ForeignKey
      category = models.ForeignKey(Category)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>class CategoryListView(APIView):
      def get(self, request):
          # How should this variable be passed to serializers.py?
          num_parameter = request.GET.get("num")
  
          category = Category.objects.all()
          serializers = CategorySerializers(category, many=True)
          return Response(serializers.data)
  </code></pre>
  
  <p>serializers.py</p>
  
  <pre><code>class SourceSerializer(serializers.ModelSerializer):
      class Meta:
          model = Source
          fields = ("id","name","amount")
  
  class CategorySerializer(serializers.ModelSerializer):
      source_set = serializers.SerializerMethodField('get_sources')
  
      def get_sources(self, category):
          sources = category.source_set.filter(amount=0)
          # I expect the code as follows,the "num_parameter" from views.py
          # sources = category.source_set.filter(amount=num_parameter)
  
          return SourceSerializer(instance=sources, many=True).data
  
      class Meta:
          model = Category
          fields = ("id", "name", "amount", "source_set")
  </code></pre>
  
  <p>Program running results：</p>
  
  <pre><code>[
      {
          "id": 1,
          "name": "study",
          "amount": "0",
          "source": [
              {
                  "id": 34,
                  "name": "java",
                  "amount": "0"
              },
              {
                  "id": 35,
                  "name": "python",
                  "amount": "0"
              }
          ]
      }
  ]
  </code></pre>
  
  <p>As annotated, modified the following code：</p>
  
  <pre><code>sources = category.source_set.filter(amount=0)
  </code></pre>
  
  <p>to</p>
  
  <pre><code>sources = category.source_set.filter(amount=num_parameter)
  </code></pre>
  
  <p>the "num_parameter" is from "CategoryListView", How to pass it to "CategorySerializer"?</p>
  
  <p>Thanks in advance.</p>