Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: tkinter mouse loading cursor 
Python :: break outside loop python 
Python :: jupyter notebook print string with variables 
Python :: fetch api flask url redirect 
Python :: crop image using opencv with height and width 
Python :: pandas parameters read 
Python :: python pipe where 
Python :: spacegoat meaning 
Python :: Optimize images in python using pillow 
Python :: torch.tensor.expand 
Python :: pytorch pad to square 
Python :: not mutable data type in python 
Python :: install wget in anaconda 
Python :: performance of extend vs append loop 
Python :: request.query_dict hubspot 
Python :: function to sort a list of points based on their x and y-coordinates 
Python :: python 3.7.8 download 
Python :: python range for loop 
Python :: pick random value from dictionary python 
Python :: pandas first row to header 
Python :: pandas integer to date 
Python :: youtube download in python 
Python :: start and end index in python 
Python :: bokeh bar chart 
Python :: write str 
Python :: package python 
Python :: create dictionary python having hash value 
Python :: global python 
Python :: python dictionary accessing an element 
Python :: how to do the sum of list in python 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =