ModelSerializer对于choice序列化器处理【详见s2-day2401项目代码】
class StaffModelSerializer(serializers.ModelSerializer):
status_text = serializers.CharField(source="get_status_display")
class Meta:
model = models.Staff
fields = '__all__'
class StaffView(BaseView, ModelViewSet):
queryset = models.Staff.objects.all()
serializer_class = StaffModelSerializer