[Fixed]-Django Rest Framework – Getting a model instance after serialization

20👍

serializer.validated_data should be used, not serializer.data

32👍

model_obj = serializer.save()

model_obj holds the model instance and you can perform actions accordingly.
or you can write create() or update() method mentioned in official doc

Deserializing objects:

https://www.django-rest-framework.org/api-guide/serializers/#deserializing-objects

Leave a comment