123456789101112131415161718192021222324252627282930 |
- from django.shortcuts import render
- # Create your views here.
- from rest_framework import status
- from rest_framework.response import Response
- from rest_framework.views import APIView
- from rest_framework.viewsets import ModelViewSet
- from workreport.models import DailyReport
- from workreport.serializers import DailyReportSerialiser
- class ReportView(APIView):
- def get(self, request):
- data = DailyReport.objects.values('title', 'content', 'content', 'create_at', 'id')
- return Response(data=data, status=status.HTTP_200_OK)
- def post(self, request):
- data = request.data
- report = DailyReport(title=data['title'], content=data['content'], create_by_id=data['create_by_id'])
- report.save()
- return Response(status=status.HTTP_201_CREATED)
- def delete(self, instance):
- pass
- class DailyReportView(ModelViewSet):
- queryset = DailyReport.objects.all()
- serializer_class = DailyReportSerialiser
|