Im trying to do a queryset to show date__month and total of all sale_prices
class RevenueChartListView(ListAPIView):
queryset = Transactions.objects.annotate(month=ExtractMonth('date')).values('month').annotate(revenue=Sum('sale_price')).order_by('month')
serializer_class = RevenueSerializer
class RevenueSerializer(serializers.ModelSerializer):
class Meta:
model = Transactions
fields = ['date', 'sale_price']
However I get an error of
"Got KeyError when attempting to get a value for field `date` on serializer `RevenueSerializer`.nThe serializer field might be named incorrectly and not match any attribute or key on the `dict` instance.nOriginal exception text was: 'date'."