Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

queryset.raw() in django rest framework joining tables

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)
 
PREVIOUS NEXT
Tagged: #django #rest #framework #joining #tables
ADD COMMENT
Topic
Name
1+4 =