tortoise-orm
tortoise-orm copied to clipboard
How tortoise implements the same functionality as SerializerMethodField in DRF?
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.