I am looking for a way to correctly oververride the .create() method for the ModelSerializer serializer in the Django Rest Framework to work with an additional parameter.
In my original Django model, I just overridden the .save() method to control the extra parameter. Now .save() can also be called as follows: .save(extra = 'foo') .
I need to create a ModelSerializer in this original Django model:
from OriginalModels.models import OriginalModel from rest_framework import serializers class OriginalModelSerializer(serializers.ModelSerializer):
But this way I can not pass the extra parameter to the .save() model method.
How can I correctly override the .create() method of my OriginalModelSerializer class to accept (eventually) this extra parameter?
python override django django-rest-framework
floatingpurr
source share