📜  django rest 框架中的 queryset.raw() 连接表 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:04.895000             🧑  作者: Mango

代码示例1
class MyModelViewSet(viewsets.ModelViewSet):
    # The usual stuff here
    model = MyModel

    def list(self, request):
        queryset = MyModel.objects.raw('... your SQL here...')
        serializer = MyModelSerializer(queryset, many=True)
        return Response(serializer.data)