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}")
原文:https://www.cnblogs.com/nieliangcai/p/12844108.html