AttributeError: Got AttributeError when attempting to get a value for field `field_name` on serializer `ModelSerializer`.
The serializer field might be named incorrectly and not match any attribute or key on the `QuerySet` instance.
Original exception text was: 'QuerySet' object has no attribute 'name'.
Solution: just add many=True on serializer class instance
Replace:
serializer = ModelSerializer(queryset)
to:
serializer = ModelSerializer(queryset, many=True)
return Response(serializer.data)
Comments
Post a Comment