Django实现列表页-----列表页删除(四)

 1 from rest_framework.views import APIView
 2 
 3 
 4 class DeleteLinkDataJson(APIView):
 5 
 6     def post(self, request):
 7         # 获取ulr中的参数 ----request.path
 8         id = request.path.split('/')[-1]
 9         data = Link.objects.filter(id=id)
10         if data:
11             data.delete()
12             return JsonResponse(f"成功删除id为{id}的链接")
13         else:
14             return JsonResponse(f"没有对应的id--{id}")

 

posted @ 2020-05-07 16:56  小心走火  阅读(254)  评论(0编辑  收藏  举报