Answers for "set value through serializer django"

0

set value through serializer django

class VariableSerializer(serializers.ModelSerializer):
    owner_name = serializers.Field(source='owner_id.owner_name')

    class Meta:
        model = Varmst
        resource_name = 'varmst'
        fields = ('varmst_id', 'varmst_type', 'varmst_name', 'varmst_value',
                  'varmst_desc')

    def transform_varmst_type(self, obj, value):
        if obj.varmst_value == 2:
            return "email"
        if obj.varmst_value == 3:
            return "Website"
Posted by: Guest on August-12-2021

Code answers related to "set value through serializer django"

Python Answers by Framework

Browse Popular Code Answers by Language