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

Popular posts from this blog

Use Djoser In Api's For Authentication In Django

DRF: Incorrect type. Expected pk value, received str - ManyToManyField in Django APIs