title: DjangoRestFramework: AttributeError: 'str' object has no attribute '_meta'
body: <p>I traced this error and found that <code>serializer.data</code> is causing the problem. I have used similar code in my other Django apps and they are running perfectly fine. </p>
  
  <p><code>models.py</code></p>
  
  <pre><code>from django.db import models
  
  class Category(models.Model):
      name=models.CharField(max_length=30)
      def __str__(self):
          return self.name
  
  class Subcategory(models.Model):
      category=models.ForeignKey(Category,on_delete=models.CASCADE)
      name=models.CharField(max_length=30)
      def __str__(self):
          return self.name
  
  class Products(models.Model):
      Subcategory=models.ForeignKey(Subcategory,on_delete=models.CASCADE)
      name=models.CharField(max_length=30)
      def __str__(self):
          return self.name    
  
  </code></pre>
  
  <p><code>serializers.py</code></p>
  
  <pre><code>from rest_framework import serializers
  from .models import Category,Subcategory,Products
  
  class CategorySerializer(serializers.ModelSerializer):
      class Meta:
          model='Category'
          fields='__all__'
  
  class SubcategorySerializer(serializers.ModelSerializer):
      class Meta:
          model='Subcategory'
          fields='__all__'
  
  class ProductsSerializer(serializers.ModelSerializer):
      class Meta:
          model='Products'
          fields='__all__'
  </code></pre>
  
  <p><code>views.py</code></p>
  
  <pre><code>    def post(self,request):
          action=request.query_params['action']
          if action=='add':
              category_name=request.query_params['category_name']
              category=Category(name=category_name)
              category.save()
              serializer=CategorySerializer(Category.objects.filter(name=category),many=True)
              return JsonResponse({"category details":serializer.data})
  </code></pre>
  
  <p>I went through all the posts on StackOverflow based on this error but none of those could help me resolve it. </p>