[Django]-Django REST Framework (AttributeError : Got AttributeError when attempting to get a value for field " " on serializer " ")

9👍

You need to add many=True in your serializer when initializing with multiple instances.

myname = NameSerializer(names,many=True)

1👍

Firstly, field names should be all lowercase, using underscores instead of camelCase, according to the official document. It’s a convention that we all should follow. ex – first_name and fore_name

And as per your question, you should write
myname = NameSerializer(names, many=True)
in views.py, because you’re trying to serialize multiple objects.

Leave a comment