I have been trying and searching alot but no one had this problem apparently. So the problem is that i am trying to send an axios request to delete with the correct api ur and key. But DRF Model.ViewSet does not find the function with appropriate PK.
Backend This is my view.py file:
class GigList(ViewSet):
def destroy(self, request, pk=None):
print(pk)
Gig.objects.filter(user=request.user, id=request.id).delete()
return Response
urls.py:
router = DefaultRouter()
router.register('api', views.GigList, basename='user')
Frontend This is the js file where axios executes:
async deleteGig(id) {
const response = await api.delete(`api/destroy/${id}` + `/`,TokenService.getLocalAccessTokenHeader() );
return response
}
Django outputs:
Not Found: /api/destroy/17/
[09/Jan/2022 23:44:46] "DELETE /api/destroy/17/ HTTP/1.1" 404 8064
If anyone has an hint or solution to this, i would be grateful, thanks guys