Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django serializer method field read write

class ProjectSerializer(serializers.ModelSerializer):
    contract_price = WritableSerializerMethodField(deserializer_field=serializers.DecimalField(max_digits=12, decimal_places=2))

    def get_contract_price(self, project):
        return project.contract_price

    def set_contract_price(self, value):
        return value
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #serializer #method #field #read #write
ADD COMMENT
Topic
Name
9+5 =