Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. # Rename Serializer Field ### Using Method ```python class ParkSerializer(serializers.ModelSerializer): location = serializers.SerializerMethodField('get_alternate_name') class Meta: model = Park fields = ('other_fields', 'location') def get_alternate_name(self, obj): return obj.alternate_name ``` ### Using Source ```python class ParkSerializer(serializers.ModelSerializer): location = serializers.CharField(source='other_fields') class Meta: model = Park fields = ('other_fields', 'location') ``` ## 출처 - https://stackoverflow.com/questions/22958058/how-to-change-field-name-in-django-rest-framework open/rename-serializer-field.txt Last modified: 2024/10/05 06:15by 127.0.0.1