1234567891011121314151617181920212223 |
- from django.db.models import Sum
- from rest_framework import status
- from rest_framework.response import Response
- from rest_framework.views import APIView
- from rest_framework.viewsets import ModelViewSet
- from basic.models import Menu
- from basic.serializer import MenuSerializer
- from payment.models import Payment
- class MenuView(ModelViewSet):
- queryset = Menu.objects.all()
- serializer_class = MenuSerializer
- pagination_class = None
- filter_fields = {'code': ['exact'], 'parent': ['exact']}
- class StatisticsView(APIView):
- def get(self, request):
- data = list(
- Payment.objects.values('payment_type').annotate(price_sum=Sum('index_price')).order_by('-price_sum'))
- return Response(data, status=status.HTTP_200_OK)
|