title: Why django-rest-framework doesn't display OneToOneField data - django
body: <p>I want to set up restful API in my site. I used django-rest-framework.
  When I get an object from database, it doesn't show related object.</p>
  
  <p>Below snippet is my first model (parent model):</p>
  
  <pre><code>class Profile(models.Model):
      user = models.OneToOneField(settings.AUTH_USER_MODEL, related_name='profile',on_delete=models.CASCADE)
      name = models.CharField(max_length=30)
      family = models.CharField(max_length=50)
  </code></pre>
  
  <p>and the below snippet is my second model (child model):</p>
  
  <pre><code>class Klass(models.Model):
      title = models.CharField(max_length=50)
      description = models.CharField(max_length=500)
      teacher = models.ForeignKey(Profile,related_name='teacher', on_delete=models.CASCADE)
      university = models.CharField(max_length=50, blank=True, null=True)
  </code></pre>
  
  <p>as you see in the second snippet, the <code>teacher</code> gets its value from <code>Profile</code> model.</p>
  
  <p>But in django-rest-framework API view, instead of displaying the teahcer's name, it displays the <code>pk</code>.</p>
  
  <p>The below snippets is my serializer and view:</p>
  
  <pre><code># serializer
  class KlassSerializer(serializers.ModelSerializer):
  
      class Meta:
          model = Klass
          fields = ('id', 'title', 'description', 'teacher')
  
  # view
  class KlassView(APIView):
  
      def get(self, request, pk=None):
          if pk is not None:
              klass = Klass.objects.filter(pk=pk).get()
              serializer = KlassSerializer(klass)
              return Response({'message': 'class get ', 'data': serializer.data,})
  </code></pre>
  
  <p>and this is the result:</p>
  
  <pre><code>{
      "message": "class get ",
      "data": {
          "id": 13,
          "title": "ُThe First Class",
          "description": "Nothing for now!",
          "teacher": 2
      }
  }
  </code></pre>
  
  <p>How can I solve the problem?
  thanks</p>