tortoise-orm icon indicating copy to clipboard operation
tortoise-orm copied to clipboard

How tortoise implements the same functionality as SerializerMethodField in DRF?

Open rubbish822 opened this issue 1 year ago • 0 comments

Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like

from rest_framework import serializers
from drf_spectacular.utils import extend_schema_field


class UserSerializer(serializers.ModelSerializer):
    full_name = serializers.SerializerMethodField(read_only=True)
    
    @extend_schema_field(serializers.CharField)
    def full_name(self, obj):
        return f'{obj.first_name}:{obj.id}'

Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

Additional context Add any other context about the feature request here.

rubbish822 avatar Jan 16 '24 03:01 rubbish822