|
@@ -33,3 +33,11 @@ class SchoolDeptViews(APIView):
|
|
# 不删除该属性会转换json错误
|
|
# 不删除该属性会转换json错误
|
|
data.pop('_state')
|
|
data.pop('_state')
|
|
return Response(data=data, status=status.HTTP_200_OK)
|
|
return Response(data=data, status=status.HTTP_200_OK)
|
|
|
|
+
|
|
|
|
+ def delete(self, request):
|
|
|
|
+ try:
|
|
|
|
+ # 当传递的id值不存在数据库或没有传id值直接捕获异常
|
|
|
|
+ data = SchoolDept.objects.get(id=request.GET.get('id')).delete()
|
|
|
|
+ except Exception:
|
|
|
|
+ return Response(data={}, status=status.HTTP_400_BAD_REQUEST)
|
|
|
|
+ return Response(data=data, status=status.HTTP_200_OK)
|