试图弄清楚我需要做些什么才能使我的DELETE方法正常工作。
请求
DELETE http://localhost:8000/api/edgeprotontoatoms/?proton_uid=bf1b364d8b084f46ac42083a8a75ad95
错误
Method Not Allowed: /api/edgeprotontoatoms/
[08/Jun/2019 02:04:22] "DELETE /api/edgeprotontoatoms/?proton_uid=bf1b364d8b084f46ac42083a8a75ad95 HTTP/1.1" 405 43
views.py
class EdgeProtonToAtomViewSet(viewsets.ViewSet):
serializer_class = EdgeProtonToAtomSerializer
def destroy(self, request, pk=None):
proton = Proton.nodes.get(uid=pk)
atoms = proton.atoms.all()
for a in atoms:
proton.atoms.disconnect(a)
return Response(status=status.HTTP_204_NO_CONTENT)
我尝试将@api_view(['DELETE'])
粘贴在'def destroy'和包含它的类上方。