title: django-rest-framwork got AttributeError when attempting to get a value for field
body: <p>I want to get all prodcut table values with join product_ratings table. I did somthing like this but this code give me <code>AttributeError</code>. So I did <code>product_ratings = ProductRatingSerializer(many=True)</code>
  in product serializer and used this value in the field, but it's not working:</p>
  <p>The full error message:</p>
  <pre><code>Got AttributeError when attempting to get a value for field `product_ratings` on serializer `ProductSerializer`.
  The serializer field might be named incorrectly and not match any attribute or key on the `Product` instance.
  Original exception text was: 'Product' object has no attribute 'product_ratings'.
  </code></pre>
  <p>view :</p>
  <pre><code>class StoreApiView(mixins.CreateModelMixin, generics.ListAPIView):
      lookup_field = 'pk'
      serializer_class = ProductSerializer
  
      def get_queryset(self):
          qs = Product.objects.all()
          query = self.request.GET.get('q')
          if query is not None:
              qs = qs.filter(
                  Q(title__icontains=query) |
                  Q(description__icontains=query)
              ).distinct()
          return qs
  </code></pre>
  <p>its serializer classes:</p>
  <pre><code>class ProductRatingSerializer(ModelSerializer):
      class Meta:
          model = Product_ratings
          fields = [
              'p_id',
              'commenter',
              'comment',
              'rating',
              'created_date',
          ]
          read_only_fields = ['p_id']
  
  
  class ProductSerializer(ModelSerializer):
      product_ratings = ProductRatingSerializer(many=True)
      author = serializers.SerializerMethodField()
  
      def get_author(self, obj):
          return obj.author.first_name
      class Meta:
          model = Product
          fields = [
              'product_id',
              'author',
              'category',
              'title',
              'description',
              'filepath',
              'price',
              'created_date',
              'updated_date',
              'product_ratings',
          ]
          read_only_fields = ['product_id', 'created_date', 'updated_date', 'author']
  </code></pre>
  <p>related model class :</p>
  <pre><code>class Product(models.Model):
      product_id = models.AutoField(primary_key=True)
      author = models.ForeignKey(User, on_delete=models.CASCADE, db_index=True)
      category = models.ForeignKey(Category, on_delete=models.CASCADE, to_field='cat_id')
      title = models.CharField(max_length=120)
      description = models.TextField(null=True, blank=True)
      price = models.CharField(max_length=50, null=True, blank=True)
      filepath = models.CharField(max_length=100, null=True, blank=True)
      created_date = models.DateTimeField(auto_now_add=True)
      updated_date = models.DateTimeField(auto_now=True)
  
  class Product_ratings(models.Model):
      p_id = models.ForeignKey(Product, on_delete=models.CASCADE, to_field='product_id')
      commenter = models.ForeignKey(User, on_delete=models.CASCADE)
      comment = models.CharField(max_length=200, null=True, blank=True)
      rating = models.IntegerField(null=True, blank=True)
      created_date = models.DateTimeField(auto_now_add=True)
  </code></pre>