title: AttributeError: 'Serializer' object has no attribute 'Meta' in django rest framework
body: <p>I am using serializers.Serializer instead of ModelSerializer which doesn't require Meta class but it keep saying object has no attribute Meta. Iam not sure what is the issue but when I run the localserver, the main page gives error saying api fetch error and in the terminal it says  AttributeError: 'Serializer' object has no attribute 'Meta'.</p>
  <p>My view:</p>
  <pre><code>class ClassView(viewsets.ModelViewSet):
      queryset = Class.objects.all().order_by('-created_at')
      serializer_class = ClassSerializer
      serializer_action_classes = {
          'get_all_students_of_a_class': ClassDetailSerializer,
      }
      # .annotate(total_students=Count('students_in_class'))
      def get_serializer_class(self):
  
          &quot;&quot;&quot;
              returns a serializer class based on the action
              that has been defined.
          &quot;&quot;&quot;
          try:
              return self.serializer_action_classes[self.action]
          except (KeyError, AttributeError):
              return super(ClassView, self).get_serializer_class()
  
     
      def get_all_students_of_a_class(self,request,pk=None):
  
          &quot;&quot;&quot;
              returns a class details with all the students signed up for the
              class along with the subject.
          &quot;&quot;&quot;
  
          id = pk
          if self.is_teacher(id):
              online_classes = get_object_or_404(Class, id=id)
              students = Student.objects.filter(online_class__id=id)
              subject_details = Subject.objects.get(online_class__id=id)
              total_students_in_class = online_classes.total_students_in_class
              created_at = online_classes.created_at
              updated_at = online_classes.updated_at
              data = {
                  &quot;teacher&quot;: self.get_teacher_instance(),
                  'total_students_in_class': total_students_in_class,
                  &quot;students_in_class&quot;: students,
                  &quot;subject&quot;: subject_details,
                  'created_at': created_at,
                  'last_updated_at': updated_at,
  
              }
              serializer_class = self.get_serializer_class()
              serializer = serializer_class(data)
              return Response(serializer.data, status=status.HTTP_200_OK)
  </code></pre>
  <p>My serializer:</p>
  <pre><code>class ClassDetailSerializer(serializers.Serializer):
      teacher = serializers.StringRelatedField()
      subject = SubjectLevelSerializer()
      total_students_in_class = serializers.ReadOnlyField()
      students_in_class = serializers.StringRelatedField(many=True)
      created_at = serializers.DateTimeField(read_only=True)
      last_updated_at =  serializers.DateTimeField(read_only=True)       
  </code></pre>
  <p>My url:</p>
  <pre><code> path(&quot;class/&lt;int:pk&gt;/&quot;,teacher.ClassView.as_view({&quot;get&quot;: &quot;get_all_students_of_a_class&quot;,&quot;delete&quot;:&quot;destroy&quot;}),
      ),
  </code></pre>
  <p>However it works and I can perform action if I go to localhost/admin and other api calls from localhost.</p>