Update/append serializer.data in Django Rest Framework [duplicate]

Unfortunately, serializer.data is a property of the class and therefore immutable. Instead of adding items to serializer.data you can copy serializer.data to another dict. You can try this:

newdict={'item':"test"}
newdict.update(serializer.data)
return Response(newdict, status=status.HTTP_201_CREATED)

Read more about property

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)