Loading

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
posted @ 2024-09-27 18:27  一只大学生  阅读(2)  评论(0编辑  收藏  举报