Closed fjbardelli closed 1 year ago
I did it:
from rest_framework.response import Response
from rest_framework.decorators import api_view
@api_view()
def inventory_stock(request):
stock = pivot(Transaction, 'product__name',
'location__name', 'quantity')
return Response(stock)
The result of a call to pivot is a list of dictionaries, as long as the values in the dictionaries are serializable you can write a serializer for it. The django-pivot library is not opinionated on what you do with the data.
is it possible to serialize the result in DRF?