title: Django Rest Framework Method returns Object of type User is not JSON serializable
body: <p>So basically I have a django method that I pass into my serializer but it returns the error <strong>Object of type User is not JSON serializable</strong> Here are my files:</p>
  <p>models.py:</p>
  <pre><code>from django.db import models
  from django.contrib.auth.models import User
  
  
  class Profile(models.Model):
      first_name = models.CharField(max_length=50, blank=True)
      last_name = models.CharField(max_length=50, blank=True)
      user = models.OneToOneField(User, on_delete=models.CASCADE)
      friends = models.ManyToManyField(User, blank=True, related_name='friends')
  
      def friends_list(self):
          return self.friends.all()
  
      def number_of_friends(self):
          return self.friends.all().count()
  </code></pre>
  <p>serialzers.py:</p>
  <pre><code>from rest_framework import serializers
  from .models import Profile
  
  
  class ProfileSerializer(serializers.ModelSerializer):
      class Meta:
          model = Profile
          fields = [
              'id',
              'first_name',
              'last_name',
              'user',
              'friends',
              'number_of_friends',
              'friends_list'
          ]
  </code></pre>
  <p>The issue comes with the &quot;friends_list&quot; method as the &quot;number_of_friends&quot; method works perfectly as intended. The entire model fields are working its just that one method that won't work. How can I resolve this?</p>