1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- from random import random
- 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 detailmptt.models import DailyMptt
- from workreport.models import DailyRreport
- from workreport.serializer import DailyReportSerializer
- class DetailMpttView(APIView):
- # def get(self,request):
- # objects_all = DailyMptt.objects.all()
- # dailyMpttList =
- #设置查询条件
- def get(self,request):
- dailyMptt = DailyMptt()
- #获取全部get信息
- params = request.GET
- #赋值
- dailyMptt.getObject(params)
- parent_id = params.get('parent_id')
- dailyMpttList = DailyMptt.objects.filter(parent_id = parent_id).values()
- return Response(data=dailyMpttList, status=status.HTTP_200_OK)
- def post(self, request):
- # pass
- data = request.data
- dailyMptt = DailyMptt()
- dailyMptt.getObject(data)
- dailyMptt.save()
- return Response(status = status.HTTP_201_CREATED)
- def delete(self, request):
- id = request.data['id']
- DailyMptt.objects.filter(id = id).delete()
- return Response(data=True, status=status.HTTP_200_OK)
|