Django Rest Framework: Deserializing and get the primary key from validated_data
After some digging, I found that the read_only
fields are only for output presentation. You can find the similar question on the offcial github link of Django REST Framework
.
So the solution is overriding the read_only
field in the serializer as follow:
class ProductlistSerializer(serializers.ModelSerializer): productlist_id = serializers.IntegerField(read_only=False) class Meta: model = Productlist fields = ('productlist_id', 'productlist_name',)