Django backend for WorkX project
25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
Bu depo arşivlendi. Dosyaları görüntüleyebilir ve klonlayabilirsiniz ama işlem gönderemez ve konu/değişiklik isteği açamazsınız.

27 satır
952 B

  1. from rest_framework.response import Response
  2. from rest_framework.views import APIView
  3. from rest_framework.authentication import TokenAuthentication, SessionAuthentication
  4. from rest_framework.permissions import IsAuthenticated
  5. from .models import Item, Invoice
  6. from .serializers import ItemSerializer, InvoiceSerializer
  7. class ItemList(APIView):
  8. authentication_classes = [TokenAuthentication, SessionAuthentication]
  9. permission_classes = [IsAuthenticated]
  10. def get(self, request):
  11. items = Item.objects.filter(pk=Item.invoice)
  12. serializer = ItemSerializer(items, many=True)
  13. return Response(serializer.data)
  14. class InvoiceList(APIView):
  15. authentication_classes = [TokenAuthentication, SessionAuthentication]
  16. permission_classes = [IsAuthenticated]
  17. def get(self, request):
  18. items = Invoice.objects.all()
  19. serializer = InvoiceSerializer(items, many=True)
  20. return Response(serializer.data)