title: Dynamically exclude or include a field in Django REST framework serializer
body: <p>I have a serializer in Django REST framework defined as follows:</p>
  
  <pre><code>class QuestionSerializer(serializers.Serializer):
      id = serializers.CharField()
      question_text = QuestionTextSerializer()
      topic = TopicSerializer()
  </code></pre>
  
  <p>Now I have two API views that use the above serializer:</p>
  
  <pre><code>class QuestionWithTopicView(generics.RetrieveAPIView):
      # I wish to include all three fields - id, question_text
      # and topic in this API.
      serializer_class = QuestionSerializer
  
  class QuestionWithoutTopicView(generics.RetrieveAPIView):
      # I want to exclude topic in this API.
      serializer_class = ExamHistorySerializer
  </code></pre>
  
  <p>One solution is to write two different serializers. But there must be a easier solution to conditionally exclude a field from a given serializer.</p>