|
@@ -23,3 +23,13 @@ class SchoolDeptViews(APIView):
|
|
|
for res in resData:
|
|
|
res['childer'] = res['childer'] // 2 != 0
|
|
|
return Response(data=resData, status=status.HTTP_200_OK)
|
|
|
+
|
|
|
+ def post(self, request):
|
|
|
+ reqData = request.data
|
|
|
+ # 获取前端给的父类id获取父类
|
|
|
+ parent = SchoolDept.objects.get(id=reqData['id'])
|
|
|
+ # 对象类型转换成dict类型
|
|
|
+ data = SchoolDept.objects.create(name=reqData['name'], parent=parent).__dict__
|
|
|
+ # 不删除该属性会转换json错误
|
|
|
+ data.pop('_state')
|
|
|
+ return Response(data=data, status=status.HTTP_200_OK)
|