Ustaw wartość za pośrednictwem 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"
Angry Alpaca